Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep compatibility of slice function #306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

knqyf263
Copy link

@knqyf263 knqyf263 commented Jun 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant