This website is running only from the browser and it uses go templates on WASM to render the templates.
For loop
Iterate over a slice and print each element.
{{ range $index, $element := .data.items }}
{{- mustToPrettyJson $element }}
{{ end }}
If statement
Check functions eq, ne, lt, le, gt, ge but arguments should be comparable types and result is boolean.
result: 10
{{if eq (int .result) 10 -}}
Result is 10
{{- else if eq (int .result) 0 -}}
Result is 0
{{- else -}}
unknown
{{- end}}
Output:
Result is 10
Range with number
Generates a sequence of integers from 0 up to (but not including) the given number.
{{ range $x := 5 }}
{{- $x }}
{{ end }}
With
Use with to limit the scope of a variable inside of a template. If we want to reach outer scope, we can use $. syntax.
{{ with .name -}}
Item {{ . }} value is {{ $.value }}
{{- end }}
Function References
Helm functions
Sprig Functions
abbrev(int, string) string
{{ abbrev 10 "Hello World" }}
Output: Hello W...
abbrevboth(int, int, string) string
{{ abbrevboth 5 10 "1234 5678 9123" }}
Output: ...5678...
add([]interface {}) int64
{{ add 1 2 3 4 5 }}
Output: 15
add1(interface {}) int64
{{ add1 1 }}
Output: 2
add1f(interface {}) float64
{{ add1f 1.1 }}
Output: 2.1
addf([]interface {}) float64
{{ addf 1.1 2.2 3.3 4.4 5.5 }}
Output: 16.5
adler32sum(string) string
{{ adler32sum "Hello World" }}
Output: 403375133
ago(interface {}) string
Timestamp to human readable time ago.
{{ ago 1687989601 }}
Output: 11s
all([]interface {}) bool
{{ all true true false }}
Output: false
any([]interface {}) bool
{{ any true true false }}
Output: true
append(interface {}, interface {}) []interface {}
First argument must be a slice.
{{ append . "add" }}
Output: [1 add]
atoi(string) int
{{ atoi "123" }}
Output: 123
b32dec(string) string
{{ b32dec "MZXW6YTBOI======" }}
Output: foobar
b32enc(string) string
{{ b32enc "foobar" }}
Output: MZXW6YTBOI======
b64dec(string) string
{{ b64dec "SGVsbG8gV29ybGQ=" }}
Output: Hello World
b64enc(string) string
{{ b64enc "Hello World" }}
Output: SGVsbG8gV29ybGQ=
base(string) string
path.Base function.
{{ base "/foo/bar/baz.js" }}
Output: baz.js
bcrypt(string) string
golang.org/x/crypto/bcrypt package's GenerateFromPassword function.
{{ bcrypt "Hello World" }}
Output: $2a$10$dTu/HetKKYglHR1bs9mBFeGkOFgIMAabTdC0TNPh5ucVJLQLTfVYG
biggest(interface {}, []interface {}) int64
{{ biggest 1 2 3 4 5 }}
Output: 5
buildCustomCert(string, string) (sprig.certificate, error)
camelcase(string) string
{{ camelcase "hello_world" }}
Output: HelloWorld
cat([]interface {}) string
{{ cat "Hello" "World" }}
Output: Hello World
ceil(interface {}) float64
{{ ceil 1.1 }}
Output: 2
chunk(int, interface {}) [][]interface {}
{{ chunk 2 (list 1 2 3 4 5) }}
Output: [[1 2] [3 4] [5]]
clean(string) string
path.Clean function.
{{ clean "/foo/bar/.." }}
Output: /foo
coalesce([]interface {}) interface {}
Returns the first non-empty value.
{{ coalesce "" "Hello World" }}
Output: Hello World
compact(interface {}) []interface {}
concat([]interface {}) interface {}
contains(string, string) bool
strings.Contains function but arguments are reversed.
{{ contains "World" "Hello World" }}
Output: true
date(string, interface {}) string
Date can be a time.Time or an int, int32, int64.
{{ date "2006-01-02" 1690151142 }}
Output: 2023-07-24
dateInZone(string, interface {}, string) string
dateModify(string, time.Time) time.Time
date_in_zone(string, interface {}, string) string
date_modify(string, time.Time) time.Time
decryptAES(string, string) (string, error)
deepCopy(interface {}) interface {}
deepEqual(interface {}, interface {}) bool
default(interface {}, []interface {}) interface {}
derivePassword(uint32, string, string, string, string) string
dict([]interface {}) map[string]interface {}
{{ dict "a" 1 "b" 2 }}
Output: map[a:1 b:2]
dig([]interface {}) (interface {}, error)
dir(string) string
path.Dir function.
{{ dir "/foo/bar/baz.js" }}
Output: /foo/bar
div(interface {}, interface {}) int64
divf(interface {}, []interface {}) float64
duration(interface {}) string
{{ duration "3600" }}
Output: 1h0m0s
durationRound(interface {}) string
empty(interface {}) bool
{{ empty "" }}
Output: true
encryptAES(string, string) (string, error)
env(string) string
{{ env "HOME" }}
Output: /home/rytsh
expandenv(string) string
{{ expandenv "$HOME" }}
{{ expandenv "${USER}" }}
Output:
/home/rytsh
rytsh
ext(string) string
path.Ext function.
{{ ext "/foo/bar/baz.js" }}
Output: .js
fail(string) (string, error)
{{ fail "FAILED PROGRAM" }}
Output: program fail, exit code 1
first(interface {}) interface {}
float64(interface {}) float64
floor(interface {}) float64
fromJson(string) interface {}
genCA(string, int) (sprig.certificate, error)
genCAWithKey(string, int, string) (sprig.certificate, error)
genPrivateKey(string) string
genSelfSignedCert(string, []interface {}, []interface {}, int) (sprig.certificate, error)
genSelfSignedCertWithKey(string, []interface {}, []interface {}, int, string) (sprig.certificate, error)
genSignedCert(string, []interface {}, []interface {}, int, sprig.certificate) (sprig.certificate, error)
genSignedCertWithKey(string, []interface {}, []interface {}, int, sprig.certificate, string) (sprig.certificate, error)
get(map[string]interface {}, string) interface {}
getHostByName(string) string
has(interface {}, interface {}) bool
hasKey(map[string]interface {}, string) bool
hasPrefix(string, string) bool
hasSuffix(string, string) bool
htmlDate(interface {}) string
htmlDateInZone(interface {}, string) string
htpasswd(string, string) string
indent(int, string) string
initial(interface {}) []interface {}
int64(interface {}) int64
join(string, interface {}) string
keys([]map[string]interface {}) []string
kindIs(string, interface {}) bool
kindOf(interface {}) string
last(interface {}) interface {}
list([]interface {}) []interface {}
max(interface {}, []interface {}) int64
maxf(interface {}, []interface {}) float64
merge(map[string]interface {}, []map[string]interface {}) interface {}
mergeOverwrite(map[string]interface {}, []map[string]interface {}) interface {}
min(interface {}, []interface {}) int64
minf(interface {}, []interface {}) float64
mod(interface {}, interface {}) int64
mul(interface {}, []interface {}) int64
mulf(interface {}, []interface {}) float64
mustAppend(interface {}, interface {}) ([]interface {}, error)
mustChunk(int, interface {}) ([][]interface {}, error)
mustCompact(interface {}) ([]interface {}, error)
mustDateModify(string, time.Time) (time.Time, error)
mustDeepCopy(interface {}) (interface {}, error)
mustFirst(interface {}) (interface {}, error)
mustFromJson(string) (interface {}, error)
mustHas(interface {}, interface {}) (bool, error)
mustInitial(interface {}) ([]interface {}, error)
mustLast(interface {}) (interface {}, error)
mustMerge(map[string]interface {}, []map[string]interface {}) (interface {}, error)
mustMergeOverwrite(map[string]interface {}, []map[string]interface {}) (interface {}, error)
mustPrepend(interface {}, interface {}) ([]interface {}, error)
mustPush(interface {}, interface {}) ([]interface {}, error)
mustRegexFind(string, string) (string, error)
mustRegexFindAll(string, string, int) ([]string, error)
mustRegexMatch(string, string) (bool, error)
mustRegexReplaceAll(string, string, string) (string, error)
mustRegexReplaceAllLiteral(string, string, string) (string, error)
mustRegexSplit(string, string, int) ([]string, error)
mustRest(interface {}) ([]interface {}, error)
mustReverse(interface {}) ([]interface {}, error)
mustSlice(interface {}, []interface {}) (interface {}, error)
mustToDate(string, string) (time.Time, error)
mustToJson(interface {}) (string, error)
mustToPrettyJson(interface {}) (string, error)
mustToRawJson(interface {}) (string, error)
mustUniq(interface {}) ([]interface {}, error)
mustWithout(interface {}, []interface {}) ([]interface {}, error)
must_date_modify(string, time.Time) (time.Time, error)
nindent(int, string) string
nothing([]interface {}) string
omit(map[string]interface {}, []string) map[string]interface {}
pick(map[string]interface {}, []string) map[string]interface {}
pluck(string, []map[string]interface {}) []interface {}
plural(string, string, int) string
prepend(interface {}, interface {}) []interface {}
push(interface {}, interface {}) []interface {}
quote([]interface {}) string
randBytes(int) (string, error)
regexFind(string, string) string
regexFindAll(string, string, int) []string
regexMatch(string, string) bool
regexQuoteMeta(string) string
regexReplaceAll(string, string, string) string
regexReplaceAllLiteral(string, string, string) string
regexSplit(string, string, int) []string
repeat(int, string) string
replace(string, string, string) string
rest(interface {}) []interface {}
reverse(interface {}) []interface {}
round(interface {}, int, []float64) float64
semver(string) (*semver.Version, error)
semverCompare(string, string) (bool, error)
set(map[string]interface {}, string, interface {}) map[string]interface {}
slice(interface {}, []interface {}) interface {}
sortAlpha(interface {}) []string
split(string, string) map[string]string
splitList(string, string) []string
splitn(string, int, string) map[string]string
squote([]interface {}) string
sub(interface {}, interface {}) int64
subf(interface {}, []interface {}) float64
substr(int, int, string) string
ternary(interface {}, interface {}, bool) interface {}
toDate(string, string) time.Time
toDecimal(interface {}) int64
toJson(interface {}) string
toPrettyJson(interface {}) string
toRawJson(interface {}) string
toString(interface {}) string
toStrings(interface {}) []string
trimAll(string, string) string
trimPrefix(string, string) string
trimSuffix(string, string) string
trimall(string, string) string
trunc(int, string) string
tuple([]interface {}) []interface {}
typeIs(string, interface {}) bool
typeIsLike(string, interface {}) bool
typeOf(interface {}) string
uniq(interface {}) []interface {}
unixEpoch(time.Time) string
unset(map[string]interface {}, string) map[string]interface {}
untilStep(int, int, int) []int
urlJoin(map[string]interface {}) string
urlParse(string) map[string]interface {}
values(map[string]interface {}) []interface {}
without(interface {}, []interface {}) []interface {}
wrapWith(int, string, string) string