mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-13 18:15:45 +00:00
Add example usage to seq function
This commit is contained in:
1 parent
36bbadecf0
commit
c830861ef7
3 files changed
+29
-7
No files matched your search
@@ -145,7 +145,7 @@ The `url` is the relative URL for the piece of content. The `url`
|
||||
* is based on the content's location within the directory structure OR
|
||||
* is defined in front matter and *overrides all the above*
|
||||
|
||||
## Overriding Default Behaviors via Front Matter
|
||||
## Overriding Destination Paths via Front Matter
|
||||
|
||||
Hugo believes that you organize your content with a purpose. The same structure that works to organize your source content is used to organize the rendered site. As displayed above, the organization of the source content will be mirrored in the destination.
|
||||
|
||||
|
||||
@@ -21,8 +21,12 @@ aliases: []
|
||||
|
||||
Works on [lists](/templates/list/), [taxonomies](/taxonomies/displaying/), [terms](/templates/terms/), [groups](/templates/list/)
|
||||
|
||||
e.g.
|
||||
## Example: All Pages Starting with 10
|
||||
|
||||
```html
|
||||
{{ range after 10 .Data.Pages }}
|
||||
{{ .Render "title" }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
|
||||
{{ range after 10 .Data.Pages }}
|
||||
{{ .Render "title" }}
|
||||
{{ end }}
|
||||
@@ -18,7 +18,7 @@ draft: false
|
||||
aliases: []
|
||||
---
|
||||
|
||||
`seq` creates a sequence of integers. It's named and used in the model of [GNU's seq][gnuseq].
|
||||
`seq` creates a sequence of integers. It's named and used in the model of [GNU's seq][].
|
||||
|
||||
```
|
||||
3 → 1, 2, 3
|
||||
@@ -28,4 +28,22 @@ aliases: []
|
||||
1 -2 → 1, 0, -1, -2
|
||||
```
|
||||
|
||||
[gnuseq]: http://www.gnu.org/software/coreutils/manual/html_node/seq-invocation.html#seq-invocation
|
||||
## Example: `seq` with `range` and `after`
|
||||
|
||||
You can use `seq` in combination with `range` and `after`. The following will return 19 elements:
|
||||
|
||||
```golang
|
||||
{{ 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`:
|
||||
|
||||
```golang
|
||||
{{ range $index, $num := (seq 20) }}
|
||||
$indexStartingAt1 := (add $index 1)
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
|
||||
[GNU's seq]: http://www.gnu.org/software/coreutils/manual/html_node/seq-invocation.html#seq-invocation
|
||||
Reference in new issue
Block a user