-
Notifications
You must be signed in to change notification settings - Fork 6
/
tabs.tpl.go
executable file
·70 lines (52 loc) · 1.45 KB
/
tabs.tpl.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//** This file was code generated by got. DO NOT EDIT. ***
package control
import (
"bytes"
"context"
"fmt"
)
func (t *Tabs) DrawTemplate(ctx context.Context, buf *bytes.Buffer) (err error) {
var children = t.Children()
if (children != nil && len(children) > 0) &&
(t.selectedID == "" || t.Child(t.selectedID) == nil) {
t.selectedID = children[0].ID() // select first item if nothing is selected
}
buf.WriteString(`
<ul class="nav nav-tabs" id="myTab" role="tablist">
`)
for _, child := range children {
buf.WriteString(` <li class="nav-item">
<a class="nav-link `)
if child.ID() == t.selectedID {
buf.WriteString(`active`)
}
buf.WriteString(`" id="`)
buf.WriteString(fmt.Sprintf("%v", child.ID()))
buf.WriteString(`_tab" data-toggle="tab" href="#`)
buf.WriteString(fmt.Sprintf("%v", child.ID()))
buf.WriteString(`" role="tab" aria-controls="`)
buf.WriteString(fmt.Sprintf("%v", child.ID()))
buf.WriteString(`" aria-selected="true">`)
buf.WriteString(fmt.Sprintf("%v", child.Text()))
buf.WriteString(`</a>
</li>
`)
}
buf.WriteString(`</ul>
<div class="tab-content" id="myTabContent">
`)
for _, child := range children {
child.AddClass("tab-pane")
if child.ID() == t.selectedID {
child.AddClass("active")
}
child.SetAttribute("role", "tabpanel")
child.SetAttribute("aria-labelledby", child.ID()+"_tab")
if err = child.Draw(ctx, buf); err != nil {
return
}
}
buf.WriteString(`</div>
`)
return
}