mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-26 22:04:32 +02:00
Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'
This commit is contained in:
@@ -1,24 +1,19 @@
|
||||
---
|
||||
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]
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
function:
|
||||
action:
|
||||
aliases: [delimit]
|
||||
returnType: template.HTML
|
||||
related:
|
||||
- functions/collections/Apply
|
||||
- functions/collections/In
|
||||
- functions/collections/Reverse
|
||||
- functions/collections/Seq
|
||||
- functions/collections/Slice
|
||||
- functions/strings/Split
|
||||
returnType: string
|
||||
signatures: ['collections.Delimit COLLECTION DELIMITER [LAST]']
|
||||
relatedFunctions:
|
||||
- collections.Apply
|
||||
- collections.Delimit
|
||||
- collections.In
|
||||
- collections.Reverse
|
||||
- collections.Seq
|
||||
- collections.Slice
|
||||
- strings.Split
|
||||
aliases: [/functions/delimit]
|
||||
---
|
||||
|
||||
@@ -26,8 +21,8 @@ Delimit a slice:
|
||||
|
||||
```go-html-template
|
||||
{{ $s := slice "b" "a" "c" }}
|
||||
{{ delimit $s ", " }} → "b, a, c"
|
||||
{{ delimit $s ", " " and "}} → "b, a and c"
|
||||
{{ delimit $s ", " }} → b, a, c
|
||||
{{ delimit $s ", " " and "}} → b, a and c
|
||||
```
|
||||
|
||||
Delimit a map:
|
||||
@@ -38,6 +33,6 @@ 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"
|
||||
{{ delimit $m ", " }} → 1, 2, 3
|
||||
{{ delimit $m ", " " and "}} → 1, 2 and 3
|
||||
```
|
||||
|
Reference in New Issue
Block a user