diff options
Diffstat (limited to 'layouts/shortcodes/tab.html')
-rw-r--r-- | layouts/shortcodes/tab.html | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/layouts/shortcodes/tab.html b/layouts/shortcodes/tab.html index c947ac4..8ec7e09 100644 --- a/layouts/shortcodes/tab.html +++ b/layouts/shortcodes/tab.html @@ -1,52 +1,52 @@ -<!-- Make sure that we are enclosed within a tabpane shortcode block --> -{{ with $.Parent }} - {{- if ne $.Parent.Name "tabpane" -}} - {{- errorf "shortcode 'tab' must be used within a 'tabpane' block" -}} - {{- end -}} -{{- end -}} +{{- /* Make sure that we are enclosed within a tabpane shortcode block */ -}} +{{ with $.Parent -}} +{{ if ne $.Parent.Name "tabpane" -}} + {{ errorf "shortcode 'tab' must be used within a 'tabpane' block" -}} + {{ end -}} +{{ end -}} -{{ $header := "Tab" }} -{{ if and (not .IsNamedParams) (.Get 0) }} - {{ $header = (.Get 0) }} -{{ else }} - <!-- Prefill header if not given as named or unnamed parameter --> - {{ $header = default (printf "Tab %v" ( add $.Ordinal 1)) (.Get "header") }} -{{ end }} +{{ $header := "Tab" -}} +{{ if and (not .IsNamedParams) (.Get 0) -}} + {{ $header = (.Get 0) -}} +{{ else -}} + {{/* Prefill header if not given as named or unnamed parameter */ -}} + {{ $header = default (printf "Tab %v" ( add $.Ordinal 1)) (.Get "header") -}} +{{ end -}} -<!-- store all tab info in dict tab --> -{{ $tab := dict "header" $header }} -{{ with $.Get "lang" }} - {{ $tab = merge $tab (dict "language" ($.Get "lang")) }} -{{ end }} -{{ with $.Get "highlight" }} - {{ $tab = merge $tab (dict "highlight" ($.Get "highlight")) }} -{{ end }} -{{ with $.Get "text" }} - {{ if ne ( printf "%T" . ) "bool" }} - {{- errorf "shortcode tab: parameter 'text' must be either true or false" -}} - {{ end }} - {{ $tab = merge $tab (dict "text" ($.Get "text")) }} -{{ end }} -{{ with $.Get "right" }} - {{ if ne ( printf "%T" . ) "bool" }} - {{- errorf "shortcode tab: parameter 'right' must be either true or false" -}} - {{ end }} - {{ $tab = merge $tab (dict "rightpush" ($.Get "right")) }} -{{ end }} -{{ with $.Get "disabled" }} - {{ if ne ( printf "%T" . ) "bool" }} - {{- errorf "shortcode tab: parameter 'disabled' must be either true or false" -}} - {{ end }} - {{ $tab = merge $tab (dict "disabled" ($.Get "disabled")) }} -{{ end }} +{{/* store all tab info in dict tab */ -}} +{{ $tab := dict "header" $header -}} +{{ with $.Get "lang" -}} + {{ $tab = merge $tab (dict "language" ($.Get "lang")) -}} +{{ end -}} +{{ with $.Get "highlight" -}} + {{ $tab = merge $tab (dict "highlight" ($.Get "highlight")) -}} +{{ end -}} +{{ with $.Get "text" -}} + {{ if ne ( printf "%T" . ) "bool" -}} + {{ errorf "shortcode tab: parameter 'text' must be either true or false" -}} + {{ end -}} + {{ $tab = merge $tab (dict "text" ($.Get "text")) -}} +{{ end -}} +{{ with $.Get "right" -}} + {{ if ne ( printf "%T" . ) "bool" -}} + {{ errorf "shortcode tab: parameter 'right' must be either true or false" -}} + {{ end -}} + {{ $tab = merge $tab (dict "rightpush" ($.Get "right")) -}} +{{ end -}} +{{ with $.Get "disabled" -}} + {{ if ne ( printf "%T" . ) "bool" -}} + {{ errorf "shortcode tab: parameter 'disabled' must be either true or false" -}} + {{ end -}} + {{ $tab = merge $tab (dict "disabled" ($.Get "disabled")) -}} +{{ end -}} -{{ with $.Inner }} - <!-- Trim any leading and trailing newlines from .Inner, this avoids - spurious lines during syntax highlighting --> - {{ $tab = merge $tab (dict "content" $.Inner ) }} -{{ end }} +{{ with $.Inner -}} + {{/* Trim any leading and trailing newlines from .Inner, this avoids + spurious lines during syntax highlighting */ -}} + {{ $tab = merge $tab (dict "content" $.Inner) -}} +{{ end -}} -<!-- add dict tab to parent's scratchpad --> -{{ with .Parent }} - {{- $.Parent.Scratch.SetInMap "tabs" (printf "%02v" $.Ordinal) $tab -}} -{{ end }} +{{/* add dict tab to parent's scratchpad */ -}} +{{ with .Parent -}} + {{ $.Parent.Scratch.SetInMap "tabs" (printf "%02v" $.Ordinal) $tab -}} +{{ end -}} |