Back to Hugo

collections.Delimit

docs/content/en/functions/collections/Delimit.md

0.161.1380 B
Original Source

Delimit a slice:

go-html-template
{{ $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.

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