/
funcs.go
45 lines (41 loc) · 1.23 KB
/
funcs.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
package main
import (
"net/url"
"text/template"
"github.com/hairyhenderson/gomplate/funcs"
)
// initFuncs - The function mappings are defined here!
func initFuncs(data *Data) template.FuncMap {
typeconv := &TypeConv{}
f := template.FuncMap{
"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,
"join": typeconv.Join,
"toJSON": typeconv.ToJSON,
"toJSONPretty": typeconv.toJSONPretty,
"toYAML": typeconv.ToYAML,
"toTOML": typeconv.ToTOML,
"toCSV": typeconv.ToCSV,
"urlParse": url.Parse,
"datasource": data.Datasource,
"ds": data.Datasource,
"datasourceExists": data.DatasourceExists,
"include": data.include,
}
funcs.AWSFuncs(f)
funcs.AddBase64Funcs(f)
funcs.AddNetFuncs(f)
funcs.AddReFuncs(f)
funcs.AddStringFuncs(f)
funcs.AddEnvFuncs(f)
return f
}