sprig. prefix is optional.
A method call passes the result before it as the method’s last argument, so sprig.now().Weekday() means Weekday(sprig.now()). Methods can be chained.
A closure is a { ... } expression that list functions such as filter and map run once per item. Inside it, # is the item, so { #.status == 'done' } is true for items whose status is done. #.field, .field and [0] read from the item. Closures support string, number, boolean and nil literals, == != > < >= <=, and/or/not (or && || !) and + - * /. Arithmetic and comparisons only work inside closures.
String:
len(value): Number of characters in a string, items in a list, or keys in an object.upper(string): Upper-casesstring.lower(string): Lower-casesstring.trim(string): Removes leading and trailing whitespace.substr(start, end, string): Characters from indexstarttoend, both inclusive (unlike Sprig):substr(0, 3, "hello")is"hell".replace(old, new, string): Replaces everyoldinstringwithnew.contains(substring, string): Whetherstringcontainssubstring.
int(value): Integer from an integer or a numeric string; also maps"Monday".."Sunday"to 1..7.asInt(value): Integer from an integer or a numeric string.randInt(min, max): Random integer frommintomax, both inclusive.
now(): Current UTC date and time.date(layout, time): Formatstimewith a Go layout, such as"2006-01-02 15:04:05","Jan 2","MST","-0700".Format(layout, time): Same asdate, usually called as a method:sprig.now().Format("15:04").Year(time): Year as a string, such as"2024".Month(time): Month name, such as"March".Day(time): Day of the month as a string, such as"5".Hour(time): Hour (0-23) as a string.Minute(time): Minute as a string.Second(time): Second as a string.Weekday(time): Weekday name, such as"Tuesday";intturns it into 1..7.YearDay(time): Day of the year as a string, such as"65".unixEpoch(time): Seconds since the Unix epoch;timecan also be an RFC 3339 string.duration(string): Parses a Go duration like"90m","1h30m"or"-1.5h", forAddandTruncate.Add(duration, time):timeshifted byduration:sprig.now().Add(sprig.duration("-24h")).Truncate(duration, time):timerounded down to a multiple ofduration, as in Go.dateModify(offset, time):timeshifted by an offset of hours, minutes and seconds, such as"-1h30m".date_modify(offset, time): Same asdateModify.
list(value, ...): List of the arguments.first(list): First item, ornullfor an empty list.chunk(size, list): Splitslistinto lists ofsizeitems.filter(list, closure): Items for whichclosureis true.map(list, closure): Result ofclosurefor each item.find(list, closure): First item for whichclosureis true, ornull.count(list, closure): Number of items for whichclosureis true.all(list, closure): Whetherclosureis true for every item.any(list, closure): Whetherclosureis true for at least one item.none(list, closure): Whetherclosureis false for every item.one(list, closure): Whetherclosureis true for exactly one item.
default(fallback, value):value, orfallbackwhenvalueis empty.empty(value): Whethervalueisnull,false,0,"",[]or{}.string(value): Debug representation, not a conversion: a string comes back wrapped in quotes and an object as%{"key" => value}. UsetoJsonto serialize.
toJson(value): Encodesvalueas a JSON string.toJSON(value): Same astoJson.fromJson(string): Decodes a JSON string; invalid JSON fails the task.fromJSON(string): Same asfromJson.b64enc(string): Base64-encodesstring.b64dec(string): Base64-decodesstring; invalid input gives the text"illegal base64 data"instead of failing.b32enc(string): Base32-encodesstring.b32dec(string): Base32-decodesstring; invalid input gives the text"illegal base32 data"instead of failing.
- String:
{"value": "{{ sprig.lower($.title).replace(\" \", \"-\") }}", "source": "fetch_post", "type": "task"}turns thetitleMy Titlefromfetch_postintomy-title. - Date:
{{ sprig.now().Add(sprig.duration("-24h")).Format("2006-01-02") }}is yesterday’s date, such as2026-10-20. - List:
{{ sprig.filter($.items, { #.status == 'done' }) }}keeps the items whosestatusisdone.