1
0
mirror of https://github.com/gohugoio/hugo.git synced 2024-05-11 05:54:58 +00:00
Bjørn Erik Pedersen ec4e6f9df2 Squashed 'docs/' content from commit f887bd7b
git-subtree-dir: docs
git-subtree-split: f887bd7b4e3e7c7e76cd63951e5b0d37d8fe0ac7
2017-08-10 17:18:22 +02:00

1.0 KiB

title description godocref date publishdate lastmod categories menu signature workson hugoversion relatedfuncs deprecated draft aliases
seq Creates a sequence of integers. 2017-02-01 2017-02-01 2017-02-01
functions
docs
parent
functions
seq LAST
seq FIRST LAST
seq FIRST INCREMENT LAST
false false

It's named and used in the model of GNU's seq.

3 → 1, 2, 3
1 2 4 → 1, 3
-3 → -1, -2, -3
1 4 → 1, 2, 3, 4
1 -2 → 1, 0, -1, -2

Example: seq with range and after

You can use seq in combination with range and after. The following will return 19 elements:

{{ range after 1 (seq 20)}}
{{ end }}

However, when ranging with an index, the following may be less confusing in that $indexStartingAt1 and $num will return 1,2,3 ... 20:

{{ range $index, $num := (seq 20) }}
$indexStartingAt1 := (add $index 1)
{{ end }}