{{/* adapted from Docsy "tabpane" shortcode */ -}} {{- $validParents := (slice "tabs" "tabpane" ) -}} {{ with $.Parent -}} {{ if not (in $validParents $.Parent.Name) -}} {{ errorf "Found shortcode %q enclosed inside a %q block, must be enclosed inside a parent shortcode of a type in %[3]T %[3]v. Error position: %[4]s" $.Name $.Parent.Name (slice "tabs" "tabpane" ) $.Position -}} {{ end -}} {{ else -}} {{ errorf "Shortcode %q must be enclosed inside a parent shortcode of a type in %[3]T %[3]v. Error position: %[4]s" $.Name $.Parent.Name (slice "tabs" "tabpane" ) $.Position -}} {{ end -}} {{ $codelang := .Get "codelang" }} {{ $header := (trim (.Get "name") " ") | default (T "tab_default" (add 1 .Ordinal)) -}} {{ if not (.Parent.Scratch.Get "tabs") -}} {{ .Parent.Scratch.Set "tabs" slice -}} {{ end -}} {{ with .Inner -}} {{ if $codelang -}} {{ $.Parent.Scratch.Add "tabs" (dict "name" $header "content" (highlight . $codelang "") ) -}} {{ else -}} {{ $.Parent.Scratch.Add "tabs" (dict "name" $header "content" . ) -}} {{ end -}} {{ else -}} {{ $include := trim (.Get "include") " "}} {{ $.Parent.Scratch.Add "tabs" (dict "name" $header "include" $include "codelang" $codelang) }} {{ end -}}