Welcome to mirror list, hosted at ThFree Co, Russian Federation.

list.html « c « shortcodes « layouts - github.com/vjeantet/hugo-theme-docport.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9ff6a05902f009a1657b9fcd1fb71de38fd828c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{{ $name := replace (.Get 0) "*" "" }}
{{ $required := strings.HasSuffix (.Get 0) "*" }}
{{ $option := .Get 1 }}
{{ $multiple := cond (eq "multi" $option) true false }}

<div class="form-group">
<select 
	name="{{$name}}" 
	required="{{cond $required `true` `false`}}" 
	{{cond $multiple `multiple` ``}}
	class="form-control">
{{ if not $multiple  }}
<option value="" selected>Choose....</option>
{{end}}

{{ range $index, $content := split (chomp .Inner) "*" }}
{{if ne $index 0}}

	{{ $id := printf "%s-%d" $name $index }}
	{{ $value := printf "option-%d" $index }}

	{{ $values := split (replaceRE `\s*(\([^\)]+\))*\s*(.*)` "$1#$2" (chomp $content)) "#" }}
	{{ $text := (index $values 1) }}
	{{ if ne "" (index $values 0)}}
		{{ $value = strings.TrimSuffix ")" (strings.TrimPrefix "(" (index $values 0)) }}
	{{end}}

<option value="{{$value}}">{{$text}}</option>

{{end}}
{{ end }}
</select>
</div>