-
Notifications
You must be signed in to change notification settings - Fork 6
/
tabs.tpl.go
executable file
·103 lines (78 loc) · 1.97 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//** This file was code generated by GoT. DO NOT EDIT. ***
package control
import (
"context"
"fmt"
"io"
)
func (t *Tabs) DrawTemplate(ctx context.Context, _w io.Writer) (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
}
if _, err = io.WriteString(_w, `
<ul class="nav nav-tabs" id="myTab" role="tablist">
`); err != nil {
return
}
for _, child := range children {
if _, err = io.WriteString(_w, ` <li class="nav-item">
<a class="nav-link `); err != nil {
return
}
if child.ID() == t.selectedID {
if _, err = io.WriteString(_w, `active`); err != nil {
return
}
}
if _, err = io.WriteString(_w, `" id="`); err != nil {
return
}
if _, err = io.WriteString(_w, fmt.Sprint(child.ID())); err != nil {
return
}
if _, err = io.WriteString(_w, `_tab" data-toggle="tab" href="#`); err != nil {
return
}
if _, err = io.WriteString(_w, fmt.Sprint(child.ID())); err != nil {
return
}
if _, err = io.WriteString(_w, `" role="tab" aria-controls="`); err != nil {
return
}
if _, err = io.WriteString(_w, fmt.Sprint(child.ID())); err != nil {
return
}
if _, err = io.WriteString(_w, `" aria-selected="true">`); err != nil {
return
}
if _, err = io.WriteString(_w, fmt.Sprint(child.Text())); err != nil {
return
}
if _, err = io.WriteString(_w, `</a>
</li>
`); err != nil {
return
}
}
if _, err = io.WriteString(_w, `</ul>
<div class="tab-content" id="myTabContent">
`); err != nil {
return
}
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")
child.Draw(ctx, _w)
}
if _, err = io.WriteString(_w, `</div>
`); err != nil {
return
}
return
}