-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest.tpl
80 lines (60 loc) · 1.11 KB
/
test.tpl
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
undefined value:
_{{.undefined}}
_{{if .undefined}}{{.undefined}}{{end}}
_{{default "" .undefined}}
empty value:
_{{.empty}}
simple string:
_{{.foo}}
null value:
_{{.null}}
special characters:
_{{.baz}}
_{{.money}}
_{{.special}}
number:
_{{.number}}
list:
_{{.bar}}
iterate over list:
{{range .bar}}_{{.}}
{{end}}
iterate over undefined:
{{range .undefined}}_{{.}}
{{end}}
iterate over list with index:
{{range $idx, $bar := .bar}}_{{$idx}}:{{$bar}}
{{end}}
access element in list:
_{{index .bar 1}}
map:
_{{.foobar}}
empty map:
_{{.whoa}}
iterate over map with key and value:
{{range $foo, $bar := .foobar}}_{{$foo}}:{{$bar}}
{{end}}
access element in map:
_{{.foobar.foo}}
access subelements:
_{{index .foobaz.foo 1}}
sprig:
_{{.foo | upper}}
_{{.bar | first}}
_{{default "foo" .undefined}}
_{{default "foo" .empty}}
backslash:
_{{.backslash}}
urls:
_{{.urls}}
include:
_{{ include "foobar.txt" }}
_{{ mustInclude "test/include.txt" | trim }}
json:
_{{ .json }}
_{{ toJson .json }}
{
{{ range $idx, $key := (keys .json) }}
{{ if gt $idx 0 }},{{ end }}{{ quote $key }}:{{ get $.json $key | quote | upper }}
{{ end }}
}