From 882aa9e5601fb927b9ee02f90c5348901ca627dc Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 16 Feb 2023 09:02:52 +0100 Subject: [PATCH] fix: fix rendering of nested shortcodes in tabs (#584) --- layouts/shortcodes/columns.html | 4 ++-- layouts/shortcodes/tab.html | 18 +++++++++--------- layouts/shortcodes/tabs.html | 10 +++++----- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/layouts/shortcodes/columns.html b/layouts/shortcodes/columns.html index 5a7bb62..ecb68a9 100644 --- a/layouts/shortcodes/columns.html +++ b/layouts/shortcodes/columns.html @@ -6,9 +6,9 @@
- {{ range split .Inner "<--->" }} + {{- range split .Inner "<--->" }}
{{ . | $.Page.RenderString }}
- {{ end }} + {{- end }}
diff --git a/layouts/shortcodes/tab.html b/layouts/shortcodes/tab.html index 4eb1b44..90b2727 100644 --- a/layouts/shortcodes/tab.html +++ b/layouts/shortcodes/tab.html @@ -1,12 +1,12 @@ -{{ if .Parent }} - {{ $name := .Get 0 }} - {{ $group := printf "tabs-%s" (.Parent.Get 0) }} +{{- if .Parent }} + {{- $name := .Get 0 }} + {{- $group := printf "tabs-%s" (.Parent.Get 0) }} - {{ if not (.Parent.Scratch.Get $group) }} - {{ .Parent.Scratch.Set $group slice }} - {{ end }} + {{- if not (.Parent.Scratch.Get $group) }} + {{- .Parent.Scratch.Set $group slice }} + {{- end }} - {{ .Parent.Scratch.Add $group (dict "Name" $name "Content" .Inner) }} -{{ else }} + {{- .Parent.Scratch.Add $group (dict "Name" $name "Content" .Inner) }} +{{- else }} {{ errorf "%q: 'tab' shortcode must be inside 'tabs' shortcode" .Page.Path }} -{{ end }} +{{- end }} diff --git a/layouts/shortcodes/tabs.html b/layouts/shortcodes/tabs.html index 660b14d..7d8671e 100644 --- a/layouts/shortcodes/tabs.html +++ b/layouts/shortcodes/tabs.html @@ -1,10 +1,10 @@ -{{ if .Inner }}{{ end }} -{{ $id := .Get 0 }} -{{ $group := printf "tabs-%s" $id }} +{{- if .Inner }}{{ end }} +{{- $id := .Get 0 }} +{{- $group := printf "tabs-%s" $id }}
- {{ range $index, $tab := .Scratch.Get $group }} + {{- range $index, $tab := .Scratch.Get $group }} {{ .Content | $.Page.RenderString }}
- {{ end }} + {{- end }}