Functions
Syntax
{{ func-name arg1, arg2, … , argX }}
Common functions
{{ truncate N }}
(Truncates to N characters long, counting spaces. ){{ truncate 10 "This is a really long string."}}
Displays in browser as: This is a …- Arithmetic
{{ add 1 5 }}
(also:sub
)
In browser: 6 range
{{ range .Pages }}
<!--Here can access variables of that page-->
{{ .Title }} <br />
{{ end }}
Used in list pages to iterate over all pages in a section.
All pages on the site: {{range .Site.Pages}}
first
,last
{{ range first 3 .Pages }}
Show only first 3.where
{{ .Range .Site.Sections.Asia.Pages where “Title” contains “Korea” }}
{{ .Title }}
{{ end }}
FYI couldn’t get even this part alone to work .Range .Site.Sections.Asia.Pages
.Range .Site.Sections.dir1.Pages
Supposed to be all pages in dir ‘Asia’ or dir ‘dir1’.