summaryrefslogtreecommitdiffstats
path: root/docs/content/en/functions/collections/Delimit.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/en/functions/collections/Delimit.md')
-rw-r--r--docs/content/en/functions/collections/Delimit.md43
1 files changed, 43 insertions, 0 deletions
diff --git a/docs/content/en/functions/collections/Delimit.md b/docs/content/en/functions/collections/Delimit.md
new file mode 100644
index 000000000..0fc3ef537
--- /dev/null
+++ b/docs/content/en/functions/collections/Delimit.md
@@ -0,0 +1,43 @@
+---
+title: collections.Delimit
+linkTitle: delimit
+description: Loops through any array, slice, or map and returns a string of all the values separated by a delimiter.
+categories: [functions]
+keywords: []
+menu:
+ docs:
+ parent: functions
+function:
+ aliases: [delimit]
+ returnType: template.HTML
+ signatures: ['collections.Delimit COLLECTION DELIMITER [LAST]']
+relatedFunctions:
+ - collections.Apply
+ - collections.Delimit
+ - collections.In
+ - collections.Reverse
+ - collections.Seq
+ - collections.Slice
+ - strings.Split
+aliases: [/functions/delimit]
+---
+
+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.
+{{% /note %}}
+
+```go-html-template
+{{ $m := dict "b" 2 "a" 1 "c" 3 }}
+{{ delimit $m ", " }} → "1, 2, 3"
+{{ delimit $m ", " " and "}} → "1, 2 and 3"
+```