Sprig functions
Adding gotmpl4j-sprig to the classpath registers the Sprig
function library via ServiceLoader — no wiring required. These are the same functions Helm
templates rely on.
1. Categories
| Category | Examples |
|---|---|
Strings |
|
Lists |
|
Dicts |
|
Math |
|
Conversion / defaults |
|
Encoding |
|
Crypto |
|
Date |
|
Semver |
|
Reflection |
|
Network / path |
|
2. Strict (must) variants
Functions that can fail come in two forms. The plain form (fromJson, toJson, index,
append, …) is lenient and returns a zero value on error, matching Sprig’s "graceful"
behavior. The must form (mustFromJson, mustToJson, mustIndex, …) raises an error
instead, so failures surface rather than silently producing empty output.
3. Example
{{ .name | default "anonymous" | title }}
{{ list 3 1 2 | sortAlpha | join "," }}
{{ dict "a" 1 "b" 2 | toJson }}
{{ now | date "2006-01-02" }}
|
A handful of functions diverge intentionally from upstream Sprig where the JVM and Go differ (for example, regular expressions use Java’s engine rather than Go’s RE2, and some date layouts map approximately). See Conformance for how parity is measured and where divergences are pinned. |