summaryrefslogtreecommitdiffstats
path: root/docs/content/en/functions/go-template/range.md
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2025-04-10 13:04:51 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2025-04-10 13:04:51 +0200
commit653f1c1d462332bccf303a5040e5cd99c89a4378 (patch)
treec993984f169a240567526e9993261241c0cda771 /docs/content/en/functions/go-template/range.md
parent208a0de6c31354df6f9463d49e90db9dec935169 (diff)
parent5be51ac3db225d5df501ed1fa1499c41d97dbf65 (diff)
downloadhugo-653f1c1d462332bccf303a5040e5cd99c89a4378.tar.gz
hugo-653f1c1d462332bccf303a5040e5cd99c89a4378.zip
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
Diffstat (limited to 'docs/content/en/functions/go-template/range.md')
-rw-r--r--docs/content/en/functions/go-template/range.md34
1 files changed, 13 insertions, 21 deletions
diff --git a/docs/content/en/functions/go-template/range.md b/docs/content/en/functions/go-template/range.md
index 96713c4b7..a06907c79 100644
--- a/docs/content/en/functions/go-template/range.md
+++ b/docs/content/en/functions/go-template/range.md
@@ -3,20 +3,15 @@ title: range
description: Iterates over a non-empty collection, binds context (the dot) to successive elements, and executes the block.
categories: []
keywords: []
-action:
- aliases: []
- related:
- - functions/go-template/break
- - functions/go-template/continue
- - functions/go-template/else
- - functions/go-template/end
- returnType:
- signatures: [range COLLECTION]
+params:
+ functions_and_methods:
+ aliases: []
+ returnType:
+ signatures: [range COLLECTION]
aliases: [/functions/range]
-toc: true
---
-{{% include "functions/go-template/_common/truthy-falsy.md" %}}
+{{% include "/_common/functions/truthy-falsy.md" %}}
```go-html-template
{{ $s := slice "foo" "bar" "baz" }}
@@ -59,9 +54,8 @@ Hugo will throw an error:
The error occurs because we are trying to use the `.Title` method on an integer instead of a `Page` object. Within the `range` block, if we want to render the page title, we need to get the context passed into the template.
-{{% note %}}
-Use the `$` to get the context passed into the template.
-{{% /note %}}
+> [!note]
+> Use the `$` to get the context passed into the template.
This template will render the page title three times:
@@ -71,11 +65,8 @@ This template will render the page title three times:
{{ end }}
```
-{{% note %}}
-Gaining a thorough understanding of context is critical for anyone writing template code.
-{{% /note %}}
-
-[`seq`]: /functions/collections/seq/
+> [!note]
+> Gaining a thorough understanding of context is critical for anyone writing template code.
## Array or slice of scalars
@@ -191,8 +182,9 @@ Is rendered to:
Unlike ranging over an array or slice, Hugo sorts by key when ranging over a map.
-{{% include "functions/go-template/_common/text-template.md" %}}
+{{% include "/_common/functions/go-template/text-template.md" %}}
-[`else`]: /functions/go-template/else/
[`break`]: /functions/go-template/break/
[`continue`]: /functions/go-template/continue/
+[`else`]: /functions/go-template/else/
+[`seq`]: /functions/collections/seq/