2025-08-15 03:09:58 +02:00
|
|
|
{{- /*
|
|
|
|
Create a tab.
|
|
|
|
|
2025-09-11 00:54:27 +02:00
|
|
|
@param {string} name The name of the tab.
|
|
|
|
@param {string} selected Whether the tab is selected.
|
|
|
|
|
|
|
|
@example {{< tab name="Foo" selected=true >}}content{{< /tab >}}
|
2025-08-15 03:09:58 +02:00
|
|
|
*/ -}}
|
|
|
|
|
2025-09-11 00:54:27 +02:00
|
|
|
{{- $name := .Get "name" | default (printf "Tab %d" .Ordinal) -}}
|
|
|
|
|
|
|
|
{{- $selected := .Get "selected" -}}
|
|
|
|
{{- if .Parent.Get "defaultIndex" -}}
|
|
|
|
{{- $selected = eq .Ordinal (int (.Parent.Get "defaultIndex")) -}}
|
|
|
|
{{- end -}}
|
2023-08-02 21:24:52 +01:00
|
|
|
|
2025-09-11 00:54:27 +02:00
|
|
|
{{- $tabs := .Parent.Store.Get "tabs" | default slice -}}
|
|
|
|
{{ .Parent.Store.Set "tabs" ($tabs | append (dict
|
|
|
|
"id" .Ordinal
|
|
|
|
"name" $name
|
|
|
|
"content" .InnerDeindent
|
|
|
|
"selected" $selected
|
|
|
|
))
|
|
|
|
-}}
|