docs/layouts/shortcodes/tabs.html
{{- $group := .Get "id" -}} {{- $level := int (.Get "level" | default "1") -}} {{- if not $group -}} {{- errorf "The %q shortcode requires an 'id' argument: see %s" .Name .Position -}} {{- end -}} {{- /* Ensure each tabs shortcode on a page gets an isolated radio group. */ -}} {{- $instance := add (default 0 (.Page.Scratch.Get "tabs-instance-counter")) 1 -}} {{- .Page.Scratch.Set "tabs-instance-counter" $instance -}} {{- $blocks := split (trim .InnerDeindent "\n\r\t ") "" -}} {{- $page := .Page -}}
{{- $checked := false -}} {{- $tabIndex := 0 -}} {{- range $index, $raw := $blocks -}} {{- $block := trim $raw "\n\r\t " -}} {{- if ne $block "" -}} {{- $tabIndex = add $tabIndex 1 -}} {{- $parts := split $block "\n\n" -}} {{- $title := trim (index $parts 0) "\n\r\t " -}} {{- $titleParts := split $title "|" -}} {{- $tabTitle := trim (index $titleParts 0) " \n\r\t" -}} {{- $iconRaw := "" -}} {{- if gt (len $titleParts) 1 -}} {{- $iconRaw = trim (index $titleParts 1) " \n\r\t" -}} {{- end -}} {{- $content := "" -}} {{- if gt (len $parts) 1 -}} {{- $content = delimit (after 1 $parts) "\n\n" -}} {{- end -}} {{- $groupName := printf "%s-%d" $group $instance -}} {{- $tabID := printf "%s-%d" $groupName $tabIndex -}} {{- $contentID := printf "%s-content-%d" $groupName $tabIndex -}} {{- if ne $iconRaw "" -}} {{- if hasPrefix $iconRaw "fa" -}} {{- else -}} {{ $iconRaw | safeHTML }} {{- end -}} {{- end -}} {{ $tabTitle }} {{- $content | $page.RenderString -}} {{- $checked = true -}} {{- end -}} {{- end -}}