mirror of
				https://github.com/imfing/hextra.git
				synced 2025-10-31 08:34:52 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			622 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			622 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
| {{- /*
 | |
| Create a tab.
 | |
| 
 | |
| @param {string} name The name of the tab.
 | |
| @param {string} selected Whether the tab is selected.
 | |
| 
 | |
| @example {{< tab name="Foo" selected=true >}}content{{< /tab >}}
 | |
| */ -}}
 | |
| 
 | |
| {{- $name := .Get "name" | default (printf "Tab %d" .Ordinal) -}}
 | |
| 
 | |
| {{- $selected := .Get "selected" -}}
 | |
| {{- if .Parent.Get "defaultIndex" -}}
 | |
|   {{- $selected = eq .Ordinal (int (.Parent.Get "defaultIndex")) -}}
 | |
| {{- end -}}
 | |
| 
 | |
| {{- $tabs := .Parent.Store.Get "tabs" | default slice -}}
 | |
| {{ .Parent.Store.Set "tabs" ($tabs | append (dict
 | |
|     "id" .Ordinal
 | |
|     "name" $name
 | |
|     "content" .InnerDeindent
 | |
|     "selected" $selected
 | |
|   ))
 | |
| -}}
 | 
