Releases: Masterminds/sprig
2.13.0 Adds New Functions
This release adds new functions, including:
regexMatch
,regexFindAll
,regexFind
,regexReplaceAll
,regexReplaceAllLiteral
, andregexSplit
to work with regular expressionsfloor
,ceil
, andround
math functionstoDate
converts a string to a datenindent
is just likeindent
but also prepends a new lineago
returns the time fromtime.Now
Changelog
Added
- #40: Added basic regex functionality (thanks @alanquillin)
- #41: Added ceil floor and round functions (thanks @alanquillin)
- #48: Added toDate function (thanks @andreynering)
- #50: Added nindent function (thanks @binoculars)
- #46: Added ago function (thanks @slayer)
Changed
- #51: Updated godocs to include new string functions (thanks @curtisallen)
- #49: Added ability to merge multiple dicts (thanks @binoculars)
New functions
This release adds several new functions:
snakecase
,camelcase
, andshuffle
are three new string functionsfail
allows you to bail out of a template render when conditions are not met
Changelog
- Fix links to other markdown docs. 967ad1c (Chance Zibolski)
- Add fail function 3ca3f10 (Kent Rancourt)
- Fix minor indentation issues 4776d72 (Luk Burchard)
- Update glide with new dependencies f5b0ed4 (Matt Butcher)
- Add 'snakecase', 'camelcase' and 'shuffle' c032c8f (Manfred Touron)
- Updated documentation on merge. eddf742 (Matt Butcher)
Two Dozen New Functions!
Inspired by the utility library underscore.js, we've added a bunch of new utility functions to Sprig. Many of these are designed to work on dict
and list
types (and for the time being, on tuple
as well).
Highlights:
semver
andsemverCompare
were added by popular demand.list
replacestuple
join
was fixed- Added:
- first
- last
- intial
- rest
- prepend
- append
- toString
- toStrings
- sortAlpha
- reverse
- coalesce
- pluck
- pick
- compact
- keys
- omit
- uniq
- has
- without
Complete changes:
Add semver and semverCompare. 23597e5 (Matt Butcher)
Add without and has functions. 1f3c301 (Matt Butcher)
Add uniq function. a1c06b6 (Matt Butcher)
Only install glide during 'make setup' if not already installed. 586619b (Matt Butcher)
Add setup target to makefile 5db9171 (Matt Butcher)
Clone the generic map instead of acting directly on it. 10f3ff0 (Matt Butcher)
Refactor into multiple files. 9e5d6d8 (Matt Butcher)
Add pick and omit functions. 44e3642 (Matt Butcher)
Add keys function. 427e901 (Matt Butcher)
Add 'compact' function. 2009c25 (Matt Butcher)
Add 'pluck' function df7a544 (Matt Butcher)
Add reverse and coalesce functions. 73a5952 (Matt Butcher)
Add toString, toStrings, and sortAlpha. df3624e (Matt Butcher)
Add list, first, last, initial, rest, prepend, and append. 3e101af (Matt Butcher)
Allow 'join' to take other array/slice types. 713da53 (Matt Butcher)
2.8.0 adds path functions and dictionary management
This release adds two new sets of functions:
- First, it provides access to several path functions (
base
,dir
,clean
,ext
, andabs
) - Second, it adds functions for mutating dictionaries (
set
,unset
,hasKey
)
UUIDv4 Function
This release adds a uuidv4
template function for generating UUIDs inside of a template.
New trimSuffix, trimPrefix, hasSuffix, and hasPrefix functions
Four new functions from the strings
package have been exposed as template functions. Following established conventions, we've reversed the order of parameters to better suite template usage:
{{"$5.00" | trimPrefix "$"}}
Additionally, new aliases have been added for a few functions that didn't follow the naming conventions. There is now a trimAll
(used in preference to trimall
) and abbrevBoth
(in preference to abbrevboth
).
At the 3.0 release (whenever that happens), trimall
and abbrevboth
will be removed.
Add until and untilStep
This release adds two functions: until
and untilStep
. These functions generate integer slices. They are designed to be used for iteration:
{{range $i, $val := until 5}}{{end}}
In the above, $i
is the index, and $val
is the value. Both will iterate from 0
to 4
.
For more control, you may use untilStep
. The above can be replicated exactly:
{{range $i, $val := until 0 5 1}}{{end}}
untilStep
takes three arguments: untilStep $start $end $step
:
$start
: The starting value$end
: The end value$step
: The increment value
Here's an example that will produce even numbers less than 10:
{{range $i, $val := until 0 10 2}}
{{$val}}
{{end}}
The above will produce
0
2
4
6
8
Add cat, replace, plural, and indent functions
New functions:
- cat: Concatenate strings with whitespace separators.
- replace: Replace parts of a string:
replace " " "-" "Me First"
renders "Me-First" - plural: Format plurals:
len "foo" | plural "one foo" "many foos"
renders "many foos" - indent: Indent blocks of text in a way that is sensitive to "\n" characters.
Add genPrivateKey
Experimenting with some new crypto functions for orchestration tasks, we've added a genPrivateKey function. Thanks to @bacongobbler for the pull request.
Improve 'default', add example, and add hermetic functions
This release adds the following:
default
now prints the default value when it does not receive a value down the pipeline. It is much safer now to do{{.Foo | default "bar"}}
.- Added accessors for "hermetic" functions. These return only functions that, when given the same input, produce the same output.