-
-
Notifications
You must be signed in to change notification settings - Fork 763
Description
Description
There is a minor error in the description of the templating basic string functions. I've copied the example from the documentation into the issue example field. The issue is in the final line, which does not run:
- echo "{{substr .TEXT 0 5}}" # "Hello"
The error given is:
template: :1:15: executing "" at <.TEXT>: wrong type for value; expected int; got string
Consulting the slim-spring documentation, the string argument should be last. Either of the following would work:
- echo "{{.TEXT | substr 0 5}}" # "Hello"
- echo "{{substr 0 5 .TEXT}}" # "Hello"
Sorry to bother you with a minor issue, but it confused me for a bit. I appreciate the work put into this project. I can do a PR if it helps, though honestly it's maybe too trivial to bother with that.
Version
3.45.4+35b03f9
Operating system
N/A
Experiments Enabled
No response
Example Taskfile
version: 3
tasks:
string-basic:
vars:
MESSAGE: ' Hello World '
NAME: 'john doe'
TEXT: "Hello World"
cmds:
- echo "{{.MESSAGE | trim}}" # "Hello World"
- echo "{{.NAME | title}}" # "John Doe"
- echo "{{.NAME | upper}}" # "JOHN DOE"
- echo "{{.MESSAGE | lower}}" # "hello world"
- echo "{{.NAME | trunc 4}}" # "john"
- echo "{{"test" | repeat 3}}" # "testtesttest"
- echo "{{substr .TEXT 0 5}}" # "Hello