#49: This integrates sprig into boilerplate
so that the sprig functions are available in the templates rendered by boilerplate. Note that there are a few
boilerplatefunctions that overlap with
sprig. Each of these are now documented in the README. As such, starting this release those helpers are deprecated, and will be replaced with the
sprig` versions in a future release. Please review the deprecation notes in the README, pasted below for convenience.
Deprecated helpers
These helpers are deprecated. They are currently available for backwards compatibility, but may be removed in future
versions. Please use the alternative supported forms listed in the description.
downcase STRING
: Same functionality as lower in sprig.upcase STRING
: Same functionality as upper in sprig.capitalize STRING
: Same functionality as title in sprig.snakeCase STRING
: Same functionality as snakecase in sprig.camelCase STRING
: Same functionality as camelcase in sprig.
The following functions overlap with sprig, but have different functionality. There is an equivalent function listed
above under a different name. These point to the boilerplate implementations for backwards compatibility. Please migrate
to using the new naming scheme, as they will be updated to use the sprig versions in future versions of boilerplate.
round
: In boilerplate,round
returns the integer form as opposed to float. E.g{{ round 123.5555 }}
will return
124
. The following supported alternative functions are available:roundFloat
: The sprig version of round, which supports
arbitrary decimal rounding. E.g{{ round 123.5555 3 }}
returns123.556
. Note that{{ round 123.5555 0 }}
returns124.0
.roundInt
: Another name for the boilerplate version ofround
. Use this if you would like to keep old behavior.
ceil
andfloor
: In boilerplate,ceil
andfloor
return integer forms as opposed to floats. E.g{{ ceil 1.1 }}
returns2
, as opposed to2.0
in the sprig version. The following supported alternative functions are
available:env
: In boilerplate,env
supports returning a default value if the environment variable is not defined. The
following supported alternative functions are available:readEnv
: The sprig version of env. This always returns empty
string if the environment variable is undefined.envWithDefault
: Another name for the boilerplate version ofenv
. Use this if you would like to keep old
behavior.
keys
: In boilerplate,keys
returns the keys of the map in sorted order. The following supported alternative
functions are available:keysUnordered
: The sprig version of keys. This returns the
list of keys in no particular order, and there is no guarantee that the order of the returned list is consistent.keysSorted
: Another name for the boilerplate version ofkeys
. Use this if you would like to keep old
behavior.
replace
: In boilerplate,replace
only replaces the first occurrence in the string, as opposed to all occurrences
as in sprig. The following supported alternative functions are available:replaceAll
: The sprig version of replace.replaceOne
: Another name for the boilerplate version ofreplace
. Use this if you would like to keep old
behavior.
slice
: In boilerplate,slice
returns a list of numbers in the provided range. E.g{{ slice 1 5 1 }}
returns
the list[1, 2, 3, 4]
. The following supported alternative functions are available:sliceList
: The sprig version of slice, which returns the
slice of the given list. E.g{{ slice list n m }}
returnslist[n:m]
.numRange
: Another name for the boilerplate version ofslice
. Use this if you would like to keep old
behavior.
trimPrefix
andtrimSuffix
: In boilerplate,trimPrefix
andtrimSuffix
takes the base string first. E.g
{{ trimPrefix hello-world hello }}
returns-world
. The following supported alternative functions are available:trimPrefixSprig
andtrimSuffixSprig
: The sprig version of
trimPrefix and
trimSuffix. Unlike the boilerplate version, this takes the trim text first so that you can pipeline the trimming. E.g{{ "hello-world" | trimPrefix "hello" }}
returns{{ -world }}
.trimPrefixBoilerplate
andtrimSuffixBoilerplate
: Another name for the boilerplate versions oftrimPrefix
andtrimSuffix
. Use this if you would like to keep old behavior.