Skip to content

Commit

Permalink
fix: fix rendering of nested shortcodes in tabs (#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxys authored Feb 16, 2023
1 parent 935b200 commit 882aa9e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions layouts/shortcodes/columns.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@


<div class="gdoc-columns gdoc-columns--{{ $size }} flex flex-gap flex-mobile-column">
{{ range split .Inner "<--->" }}
{{- range split .Inner "<--->" }}
<div class="gdoc-columns__content gdoc-markdown--nested flex-even">
{{ . | $.Page.RenderString }}
</div>
{{ end }}
{{- end }}
</div>
18 changes: 9 additions & 9 deletions layouts/shortcodes/tab.html
Original file line number Diff line number Diff line change
@@ -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 }}
10 changes: 5 additions & 5 deletions layouts/shortcodes/tabs.html
Original file line number Diff line number Diff line change
@@ -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 }}


<div class="gdoc-tabs">
{{ range $index, $tab := .Scratch.Get $group }}
{{- range $index, $tab := .Scratch.Get $group }}
<input
type="radio"
class="gdoc-tabs__control hidden"
Expand All @@ -18,5 +18,5 @@
<div class="gdoc-markdown--nested gdoc-tabs__content">
{{ .Content | $.Page.RenderString }}
</div>
{{ end }}
{{- end }}
</div>

0 comments on commit 882aa9e

Please sign in to comment.