mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-31 22:41:53 +02:00
Merge commit 'f96384a3b596f9bc0a3a035970b09b2c601f0ccb'
This commit is contained in:
@@ -1,38 +1,19 @@
|
||||
---
|
||||
title: shuffle
|
||||
# linktitle:
|
||||
description: Returns a random permutation of a given array or slice.
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-04-30
|
||||
keywords: [ordering]
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
parent: functions
|
||||
signature: ["shuffle COLLECTION"]
|
||||
workson: []
|
||||
hugoversion:
|
||||
relatedfuncs: [seq]
|
||||
deprecated: false
|
||||
draft: false
|
||||
aliases: []
|
||||
---
|
||||
|
||||
{{< code file="shuffle-input.html" >}}
|
||||
<!-- Shuffled sequence = -->
|
||||
<div>{{ shuffle (seq 1 5) }}</div>
|
||||
<!-- Shuffled slice = -->
|
||||
<div>{{ shuffle (slice "foo" "bar" "buzz") }}</div>
|
||||
{{< /code >}}
|
||||
|
||||
This example would return the following:
|
||||
```go-html-template
|
||||
{{ shuffle (seq 1 2 3) }} → [3 1 2]
|
||||
{{ shuffle (slice "a" "b" "c") }} → [b a c]
|
||||
```
|
||||
|
||||
{{< output file="shuffle-output.html" >}}
|
||||
<!-- Shuffled sequence = -->
|
||||
<div>2 5 3 1 4</div>
|
||||
<!-- Shuffled slice = -->
|
||||
<div>buzz foo bar</div>
|
||||
{{< /output >}}
|
||||
|
||||
This example also makes use of the [slice](/functions/slice/) and [seq](/functions/seq/) functions.
|
||||
The result will vary from one build to the next.
|
||||
|
Reference in New Issue
Block a user