mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Add index reference to go template primer doc page
Related to @bjornerik 's answer in this discussion: http://discuss.gohugo.io/t/inserting-data-from-data-file-into-content-file-newbie-question/1002/3 ... I figured I'd make myself useful and add the reference to the index function, on the go template primer page. Also, I moved the reference links to the bottom. A general comment: as good as these docs are, the primer at this point makes some assumptions about audience knowledge, so some might find it lacking. Once I understand better, I might make some more clarifying edits.
This commit is contained in:
parent
be15b07733
commit
da08fad5f3
1 changed files with 8 additions and 4 deletions
|
@ -144,6 +144,10 @@ range.
|
||||||
{{ $element }}
|
{{ $element }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
The `index` function is a [Go][] built-in, and you can read about it [here][gostdlibpkgtexttemplate]. `index`:
|
||||||
|
|
||||||
|
> ...returns the result of indexing its first argument by the following arguments. Thus "index x 1 2 3" is, in Go syntax, `x[1][2][3]`. Each indexed item must be a map, slice, or array.
|
||||||
|
|
||||||
### Conditionals
|
### Conditionals
|
||||||
|
|
||||||
`if`, `else`, `with`, `or` & `and` provide the framework for handling conditional
|
`if`, `else`, `with`, `or` & `and` provide the framework for handling conditional
|
||||||
|
@ -383,10 +387,6 @@ so, such as in this example:
|
||||||
</nav>
|
</nav>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
[go]: http://golang.org/
|
|
||||||
[gohtmltemplate]: http://golang.org/pkg/html/template/
|
|
||||||
|
|
||||||
# Template example: Show only upcoming events
|
# Template example: Show only upcoming events
|
||||||
|
|
||||||
Go allows you to do more than what's shown here. Using Hugo's
|
Go allows you to do more than what's shown here. Using Hugo's
|
||||||
|
@ -406,3 +406,7 @@ the future:
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
[go]: http://golang.org/
|
||||||
|
[gohtmltemplate]: http://golang.org/pkg/html/template/
|
||||||
|
[gostdlibpkgtexttemplate]: http://golang.org/pkg/text/template/
|
||||||
|
|
Loading…
Reference in a new issue