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
|
package main
import (
"net/url"
"strings"
"text/template"
"github.com/hairyhenderson/gomplate/funcs"
)
// initFuncs - The function mappings are defined here!
func initFuncs(data *Data) template.FuncMap {
env := &Env{}
typeconv := &TypeConv{}
stringfunc := &stringFunc{}
f := template.FuncMap{
"getenv": env.Getenv,
"bool": typeconv.Bool,
"has": typeconv.Has,
"json": typeconv.JSON,
"jsonArray": typeconv.JSONArray,
"yaml": typeconv.YAML,
"yamlArray": typeconv.YAMLArray,
"toml": typeconv.TOML,
"csv": typeconv.CSV,
"csvByRow": typeconv.CSVByRow,
"csvByColumn": typeconv.CSVByColumn,
"slice": typeconv.Slice,
"indent": typeconv.indent,
"join": typeconv.Join,
"toJSON": typeconv.ToJSON,
"toJSONPretty": typeconv.toJSONPretty,
"toYAML": typeconv.ToYAML,
"toTOML": typeconv.ToTOML,
"toCSV": typeconv.ToCSV,
"contains": strings.Contains,
"hasPrefix": strings.HasPrefix,
"hasSuffix": strings.HasSuffix,
"replaceAll": stringfunc.replaceAll,
"split": strings.Split,
"splitN": strings.SplitN,
"title": strings.Title,
"toUpper": strings.ToUpper,
"toLower": strings.ToLower,
"trim": strings.Trim,
"trimSpace": strings.TrimSpace,
"urlParse": url.Parse,
"datasource": data.Datasource,
"ds": data.Datasource,
"datasourceExists": data.DatasourceExists,
"include": data.include,
}
funcs.AWSFuncs(f)
funcs.AddBase64Funcs(f)
funcs.AddNetFuncs(f)
return f
}
|