sprig
sprig copied to clipboard
Keep compatibility of slice function
Predefined global functions also have slice
.
https://golang.org/pkg/text/template/#hdr-Functions
It takes a string, slice, or array as the first argument.
slice returns the result of slicing its first argument by the remaining arguments. Thus "slice x 1 2" is, in Go syntax, x[1:2], while "slice x" is x[:], "slice x 1" is x[1:], and "slice x 1 2 3" is x[1:2:3]. The first argument must be a string, slice, or array.
On the other hand, slice
from Sprig doesn't take a string. It breaks compatibility.
https://play.golang.org/p/NPEYDpGjtx7
IMHO, the same template should work as is after introducing Sprig. Thanks.