Skip to content
Template Functions

Template Functions

Templates have access to 200+ functions provided by Sprout, plus a set of specs-specific functions.

Specs functions

FunctionSignatureDescription
hostnamehostnamestringSystem hostname
usernameusernamestringCurrent OS username
toBinarytoBinary <int>stringInteger to binary string
formatFilesizeformatFilesize <bytes>stringHuman-readable file size (e.g. "1.0 MB")
passwordpassword <length> <digits> <symbols> <noUpper> <allowRepeat>stringGenerate a secure random password
Default registry: {{ hostname }}.azurecr.io
Author: {{ username }}
Secret key: {{ password 32 4 4 false false }}

Sprout function categories

CategoryExample functions
StringstoUpper, toLower, toPascalCase, toSnakeCase, toKebabCase, trim, replace, contains, repeat
Encodingbase64Encode, base64Decode, toJson, fromJson, toYaml, fromYaml
RegexregexMatch, regexFind, regexReplaceAll
Collectionslist, dict, append, prepend, uniq, keys, values, merge
Date & timenow, date, dateModify, dateAgo, duration
Identityuuidv4, uuidv5
Cryptosha256sum, sha1sum, md5sum, bcrypt
Numericadd, sub, mul, div, mod, floor, ceil, round
Semversemver, semverCompare
NetworkgetHostByName
RandomrandInt, randAlpha, randAlphaNum, randAscii
ReflectiontypeOf, kindOf, kindIs
Environmentenv, expandenv (disabled in --safe-mode)
FilesystemosBase, osDir, osExt (disabled in --safe-mode)

Note: Sprout uses Go-convention camelCase names. If you’re migrating from sprig, see the rename table for the full mapping.

Full function reference: docs.gosprout.dev.