hugo/docs/content/en/functions/delimit.md
2023-05-22 16:47:07 +02:00

695 B

title description categories menu keywords signature relatedfuncs
delimit Loops through any array, slice, or map and returns a string of all the values separated by a delimiter.
functions
docs
parent
functions
iteration
delimit COLLECTION DELIMITER [LAST]

Delimit a slice:

{{ $s := slice "b" "a" "c" }}
{{ delimit $s ", " }} → "b, a, c"
{{ delimit $s ", " " and "}} → "b, a and c"

Delimit a map:

{{% note %}} The delimit function sorts maps by key, returning the values. {{% /note %}}

{{ $m := dict "b" 2 "a" 1 "c" 3 }}
{{ delimit $m ", " }} → "1, 2, 3"
{{ delimit $m ", " " and "}} → "1, 2 and 3"