{{/* Check parameter types */ -}} {{ $tpPersistAttrName := "data-td-tp-persist" -}} {{ with .Get "langEqualsHeader" -}} {{ if ne ( printf "%T" . ) "bool" -}} {{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "langEqualsHeader" (printf "%T" .) $.Position -}} {{ end -}} {{ end -}} {{ with .Get "text" -}} {{ if ne ( printf "%T" . ) "bool" -}} {{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "text" (printf "%T" .) $.Position -}} {{ end -}} {{ end -}} {{ $_persistLang := .Get "persistLang" -}} {{ if and (ne $_persistLang nil) (ne $_persistLang "") -}} {{ if ne ( printf "%T" $_persistLang ) "bool" -}} {{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "persistLang" (printf "%T" $_persistLang) $.Position -}} {{ else -}} {{ warnf "Shortcode %q parameter `persistLang` is deprecated, use `persist` instead: %s" $.Name $.Position -}} {{ end -}} {{ end -}} {{ $_persist := .Get "persist" -}} {{ with $_persist -}} {{ $matched := findRE "^(header|lang|disabled)$" . -}} {{ if not $matched -}} {{ errorf "Shortcode %q: parameter %q should be one of 'header', 'lang', or 'disabled'; but got %s. Error position: %s" $.Name "persist" $_persist $.Position -}} {{ end -}} {{ end -}} {{ with .Get "right" -}} {{ if ne ( printf "%T" . ) "bool" -}} {{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "right" (printf "%T" .) $.Position -}} {{ end -}} {{ end -}} {{/* Set values given defined within tabpane */ -}} {{ $langPane := default "" ($.Get "lang") -}} {{ $hloptionsPane := default "" ($.Get "highlight") -}} {{ $textPane := default false ($.Get "text") -}} {{ $langEqualsHeader := default false ($.Get "langEqualsHeader") -}} {{ $deprecatedPersistLang := $_persistLang | default true -}} {{ $persistKeyKind := $_persist | default (cond (or $textPane (ne "" $langPane)) "header" "lang") -}} {{ $persistTabpane := and $deprecatedPersistLang (ne $persistKeyKind "disabled") -}} {{ $rightPane := default false ($.Get "right") -}} {{ $activeSet := false -}} {{/* Scratchpad gets populated through call to .Inner */ -}} {{ .Inner -}} {{ $duplicate := false -}} {{ $duplicateKey := "" -}} {{ $persistKeyList := slice -}} {{ $tabPaneOrdinal := .Ordinal -}} {{/* Nav tabs */ -}} {{ if $duplicate -}} {{ warnf "Shortcode %q: duplicate tab-persistence key %q detected, disabling persistance to avoid multiple tab display. Position: %s" $.Name $duplicateKey $.Position -}} {{ end -}} {{ $activeSet = false -}} {{/* Tab panes */ -}}
{{- range $index, $element := $.Scratch.Get "tabs" -}} {{ $lang := $langPane -}} {{ if $langEqualsHeader -}} {{ $lang = $element.header -}} {{ end -}} {{ with $element.language -}} {{ $lang = . -}} {{ end -}} {{ $enabled := not $element.disabled -}} {{ $hloptions := $hloptionsPane -}} {{ with $element.highlight -}} {{ $hloptions = . -}} {{ end -}} {{ $text := $textPane -}} {{ with $element.text -}} {{ $text = . }} {{ end -}} {{ $tabid := printf "tabs-%02v-%v-tab" $tabPaneOrdinal $index | anchorize -}} {{ $entryid := printf "tabs-%02v-%v" $tabPaneOrdinal $index | anchorize }} {{ $isActive := and $enabled (not $activeSet) -}}
{{ if $text -}} {{ index . "content" -}} {{ else -}} {{ highlight (trim (index . "content") "\r\n") $lang $hloptions -}} {{ end }}
{{- end }}