mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-26 22:04:32 +02:00
Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'
``` git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash ``` Closes #11925
This commit is contained in:
33
docs/content/en/functions/collections/Delimit.md
Normal file
33
docs/content/en/functions/collections/Delimit.md
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: collections.Delimit
|
||||
description: Loops through any array, slice, or map and returns a string of all the values separated by a delimiter.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [delimit]
|
||||
related:
|
||||
- functions/strings/Split
|
||||
returnType: string
|
||||
signatures: ['collections.Delimit COLLECTION DELIMITER [LAST]']
|
||||
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
|
||||
```
|
Reference in New Issue
Block a user