hugo/docs/content/en/functions/collections/Delimit.md
2023-10-20 09:43:56 +02:00

971 B

title linkTitle description categories keywords menu function relatedFunctions aliases
collections.Delimit delimit Loops through any array, slice, or map and returns a string of all the values separated by a delimiter.
functions
docs
parent
functions
aliases returnType signatures
delimit
template.HTML
collections.Delimit COLLECTION DELIMITER [LAST]
collections.Apply
collections.Delimit
collections.In
collections.Reverse
collections.Seq
collections.Slice
strings.Split
/functions/delimit

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"