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