delimit

将以下英文翻译为中文:

delimit

https://gohugo.io/functions/delimit/

Loops through any array, slice, or map and returns a string of all the values separated by a delimiter.

语法

delimit COLLECTION DELIMITER [LAST]

Delimit a slice:

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

Delimit a map:

The delimit function sorts maps by key, returning the values.

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

另请参阅