73f355ceUpdate theme83ff50c2Use example.com in examples71292134Add alias news > release-notes2e15f642Update theme8eef09d2Add Pygments configuration572b9e75Clean up the code shortcode usea1b2fd3bRemove the code fence language codes1473b1d9Remove redundant textb92c2042Update theme8f439c28Edit contributing section in README8bcf8a19Add contributing section to README4c44ee1cFix broken content file2bdc7710Clarify .Data.Pages sorting in lists.md092271c2Use infinitive mood for main titlesb9b8abefUpdate theme to reflect change to home page contentb897b71bChange copy to use sentence casefd675ee5Enable RSS feed for sections060a5e27Correct movie title in taxonomies.md6a5ca96aUpdate displayed site name for Hub22f4b7a4Add example of starting up the local serverd9612cb3Update themea8c3988aUpdate theme4198189dUpdate theme12d6b016Update theme2b1c4197Update themeb6d90a1eFix News release titlescfe751dbAdd some build info to README git-subtree-dir: docs git-subtree-split:73f355ce0d
1.8 KiB
title, description, godocref, workson, date, publishdate, lastmod, categories, menu, toc, signature, workson, hugoversion, relatedfuncs, deprecated, draft, aliases
| title | description | godocref | workson | date | publishdate | lastmod | categories | menu | toc | signature | workson | hugoversion | relatedfuncs | deprecated | draft | aliases | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| delimit | Loops through any array, slice, or map and returns a string of all the values separated by a delimiter. | 2017-02-01 | 2017-02-01 | 2017-02-01 |
|
|
false |
|
|
false | false |
title: delimit description: Loops through any array, slice, or map and returns a string of all the values separated by a delimiter. godocref: workson: [] date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-02-01 categories: [functions] menu: docs: parent: "functions" #tags: [iteration] toc: false signature: ["delimit COLLECTION DELIMIT LAST"] workson: [lists,taxonomies,terms] hugoversion: relatedfuncs: [] deprecated: false draft: false aliases: []
delimit called in your template takes the form of
{{ delimit array/slice/map delimiter optionallastdelimiter}}
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.
To maintain a consistent output order, maps will be sorted by keys and only a slice of the values will be returned.
The examples of delimit that follow all use the same front matter:
{{< code file="delimit-example-front-matter.toml" nocopy="true" >}} +++ title: I love Delimit #tags: [ "tag1", "tag2", "tag3" ] +++ {{< /code >}}
{{< code file="delimit-page-tags-input.html" >}}
Tags: {{ delimit .Params.tags ", " }}
{{< /code >}}{{% output file="delimit-page-tags-output.html" %}}
<p>Tags: tag1, tag2, tag3</p>
{{% /output %}}
Here is the same example but with the optional "last" delimiter:
{{< code file="delimit-page-tags-final-and-input.html" >}} Tags: {{ delimit .Params.tags ", " ", and " }} {{< /code >}}
{{% output file="delimit-page-tags-final-and-output.html" %}}
<p>Tags: tag1, tag2, and tag3</p>
{{% /output %}}