Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'

This commit is contained in:
Bjørn Erik Pedersen
2025-04-10 13:04:51 +02:00
987 changed files with 12379 additions and 14083 deletions

View File

@@ -1,31 +1,31 @@
---
title: Parent
description: Returns the parent shortcode context in nested shortcodes.
description: Returns the parent shortcode context in nested shortcodes.
categories: []
keywords: []
action:
related: []
returnType: hugolib.ShortcodeWithPage
signatures: [SHORTCODE.Parent]
params:
functions_and_methods:
returnType: hugolib.ShortcodeWithPage
signatures: [SHORTCODE.Parent]
---
This is useful for inheritance of common shortcode arguments from the root.
In this contrived example, the "greeting" shortcode is the parent, and the "now" shortcode is child.
{{< code file=content/welcome.md lang=md >}}
```text {file="content/welcome.md"}
{{</* greeting dateFormat="Jan 2, 2006" */>}}
Welcome. Today is {{</* now */>}}.
{{</* /greeting */>}}
{{< /code >}}
```
{{< code file=layouts/shortcodes/greeting.html >}}
```go-html-template {file="layouts/shortcodes/greeting.html"}
<div class="greeting">
{{ .Inner | strings.TrimSpace | .Page.RenderString }}
</div>
{{< /code >}}
```
{{< code file=layouts/shortcodes/now.html >}}
```go-html-template {file="layouts/shortcodes/now.html"}
{{- $dateFormat := "January 2, 2006 15:04:05" }}
{{- with .Params }}
@@ -41,7 +41,7 @@ Welcome. Today is {{</* now */>}}.
{{- end }}
{{- now | time.Format $dateFormat -}}
{{< /code >}}
```
The "now" shortcode formats the current time using: