-
Notifications
You must be signed in to change notification settings - Fork 4
/
funcmap.go
174 lines (165 loc) · 3.62 KB
/
funcmap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// Copyright 2018 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by the Blue Oak Model License
// license that can be found in the LICENSE file.
package funcmap
import "text/template"
// Funcs is a map of custom template functions.
var Funcs = map[string]interface{}{
"append": Append,
"base64Decode": DecodeBase64,
"base64Encode": EncodeBase64,
"chomp": Chomp,
"contains": Contains,
"containsAny": ContainsAny,
"dateFormat": TimeFormat,
"env": Getenv,
"getenv": Getenv,
"findRE": FindRE,
"fileExists": FileExists,
"firstUpper": FirstUpper,
"htmlEscape": HTMLEscape,
"htmlUnescape": HTMLUnescape,
"hasPrefix": HasPrefix,
"hasSuffix": HasSuffix,
"jsonify": EncodeJSON,
"jsonEncode": EncodeJSON,
"jsonDecode": DecodeJSON,
"lower": ToLower,
"md5": MD5,
"now": Now,
"padLeft": PadLeft,
"padRight": PadRight,
"prepend": Prepend,
"readDir": ReadDir,
"readFile": ReadFile,
"replace": Replace,
"replaceRE": ReplaceRE,
"repeat": Repeat,
"sha1": SHA1,
"sha256": SHA256,
"slicestr": SliceString,
"split": Split,
"splitn": SplitN,
"stat": Stat,
"title": ToTitle,
"time": Time,
"trimLeft": TrimLeft,
"trimRight": TrimRight,
"trimPrefix": TrimPrefix,
"trimSuffix": TrimSuffix,
"trim": Trim,
"upper": ToUpper,
"urlize": Urlize,
"yamlEncode": EncodeYAML,
"yamlDecode": DecodeYAML,
}
// SafeFuncs is a map of custom template functions. Functions
// that expose the environment and filesystem are excluded.
var SafeFuncs = map[string]interface{}{
"append": Append,
"base64Decode": DecodeBase64,
"base64Encode": EncodeBase64,
"chomp": Chomp,
"contains": Contains,
"containsAny": ContainsAny,
"dateFormat": TimeFormat,
"findRE": FindRE,
"firstUpper": FirstUpper,
"htmlEscape": HTMLEscape,
"htmlUnescape": HTMLUnescape,
"hasPrefix": HasPrefix,
"hasSuffix": HasSuffix,
"jsonify": EncodeJSON,
"jsonEncode": EncodeJSON,
"jsonDecode": DecodeJSON,
"lower": ToLower,
"md5": MD5,
"now": Now,
"padLeft": PadLeft,
"padRight": PadRight,
"prepend": Prepend,
"repeat": Repeat,
"replace": Replace,
"replaceRE": ReplaceRE,
"sha1": SHA1,
"sha256": SHA256,
"slicestr": SliceString,
"split": Split,
"splitn": SplitN,
"title": ToTitle,
"time": Time,
"trimLeft": TrimLeft,
"trimRight": TrimRight,
"trimPrefix": TrimPrefix,
"trimSuffix": TrimSuffix,
"trim": Trim,
"upper": ToUpper,
"urlize": Urlize,
"yamlEncode": EncodeYAML,
"yamlDecode": DecodeYAML,
}
// Combine combines function maps.
func Combine(funcmaps ...map[string]interface{}) template.FuncMap {
result := map[string]interface{}{}
for _, funcmap := range funcmaps {
for k, v := range funcmap {
result[k] = v
}
}
return result
}
// after
// apply
// cond
// default
// delimit
// dict
// echoParam
// first
// float
// in
// int
// intersect
// isset
// last
// pluralize
// querify
// range
// seq
// shuffle
// slice
// sort
// string
// substr
// union
// uniq
// where
//
// ------------------------------------------
//
// WONT IMPLEMENT
// safeCSS
// safeHTML
// safeHTMLAttr
// safeJS
// safeURL
// plainify
// markdownify
// emojify
// countrunes
// countwords
// highlight
// singularize
// truncate
// humanize
// urls.Parse
// SPECIFIC TO HUGO
// ref
// relLangURL
// relURL
// relref
// i18n
// partialCached
// lang.NumFmt
// imageConfig
// render