hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

delimit.md (1857B)

    1 ---
    2 title: delimit
    3 description: Loops through any array, slice, or map and returns a string of all the values separated by a delimiter.
    4 date: 2017-02-01
    5 publishdate: 2017-02-01
    6 lastmod: 2017-02-01
    7 categories: [functions]
    8 menu:
    9   docs:
   10     parent: "functions"
   11 keywords: [iteration]
   12 toc: false
   13 signature: ["delimit COLLECTION DELIMIT LAST"]
   14 workson: [lists,taxonomies,terms]
   15 hugoversion:
   16 relatedfuncs: []
   17 deprecated: false
   18 draft: false
   19 aliases: []
   20 ---
   21 
   22 `delimit` called in your template takes the form of
   23 
   24 ```
   25 {{ delimit array/slice/map delimiter optionallastdelimiter}}
   26 ```
   27 
   28 `delimit` loops through any array, slice, or map and returns a string of all the values separated by a delimiter, the second argument in the function call. There is an optional third parameter that lets you choose a different delimiter to go between the last two values in the loop.
   29 
   30 To maintain a consistent output order, maps will be sorted by keys and only a slice of the values will be returned.
   31 
   32 The examples of `delimit` that follow all use the same front matter:
   33 
   34 {{< code file="delimit-example-front-matter.toml" nocopy="true" >}}
   35 +++
   36 title: I love Delimit
   37 tags: [ "tag1", "tag2", "tag3" ]
   38 +++
   39 {{< /code >}}
   40 
   41 {{< code file="delimit-page-tags-input.html" >}}
   42 <p>Tags: {{ delimit .Params.tags ", " }}</p>
   43 {{< /code >}}
   44 
   45 {{< output file="delimit-page-tags-output.html" >}}
   46 <p>Tags: tag1, tag2, tag3</p>
   47 {{< /output >}}
   48 
   49 Here is the same example but with the optional "last" delimiter:
   50 
   51 {{< code file="delimit-page-tags-final-and-input.html" >}}
   52 Tags: {{ delimit .Params.tags ", " ", and " }}
   53 {{< /code >}}
   54 
   55 {{< output file="delimit-page-tags-final-and-output.html" >}}
   56 <p>Tags: tag1, tag2, and tag3</p>
   57 {{< /output >}}
   58 
   59 
   60 [lists]: /templates/lists/
   61 [taxonomies]: /templates/taxonomy-templates/#taxonomy-list-templates
   62 [terms]: /templates/taxonomy-templates/#terms-list-templates