github.com/jbramsden/hugo@v0.47.1/docs/content/en/functions/delimit.md (about)

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