From c830861ef7529e93f4fcffc65b813dd16908d8d6 Mon Sep 17 00:00:00 2001 From: Ryan Watters Date: Wed, 22 Mar 2017 13:19:29 -0500 Subject: [PATCH] Add example usage to seq function --- content/content-management/organization.md | 2 +- content/functions/after.md | 12 ++++++++---- content/functions/seq.md | 22 ++++++++++++++++++++-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/content/content-management/organization.md b/content/content-management/organization.md index 94f899d1d..d12df5027 100644 --- a/content/content-management/organization.md +++ b/content/content-management/organization.md @@ -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. diff --git a/content/functions/after.md b/content/functions/after.md index 15d5ed986..7057c5fca 100644 --- a/content/functions/after.md +++ b/content/functions/after.md @@ -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 }} diff --git a/content/functions/seq.md b/content/functions/seq.md index de195c8dc..a7a97cc8d 100644 --- a/content/functions/seq.md +++ b/content/functions/seq.md @@ -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 \ No newline at end of file +## 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 \ No newline at end of file