-
Notifications
You must be signed in to change notification settings - Fork 6
/
navbar.tpl.go
executable file
·165 lines (127 loc) · 3.1 KB
/
navbar.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//** This file was code generated by GoT. DO NOT EDIT. ***
package control
import (
"context"
"io"
)
func (b *Navbar) DrawTemplate(ctx context.Context, _w io.Writer) (err error) {
if _, err = io.WriteString(_w, ` <div class="`); err != nil {
return
}
if _, err = io.WriteString(_w, string(b.containerClass)); err != nil {
return
}
if _, err = io.WriteString(_w, `">
`); err != nil {
return
}
if err = b.drawToggleAndBrand(ctx, _w); err != nil {
return
}
if _, err = io.WriteString(_w, ` <div class="collapse navbar-collapse" id="`); err != nil {
return
}
if _, err = io.WriteString(_w, b.ID()); err != nil {
return
}
if _, err = io.WriteString(_w, `_collapse">
`); err != nil {
return
}
if b.brandLocation == NavbarCollapsedBrandHidden {
b.drawBrand(ctx, _w)
}
if _, err = io.WriteString(_w, `
`); err != nil {
return
}
b.DrawChildren(ctx, _w)
if _, err = io.WriteString(_w, `
</div>
</div>
`); err != nil {
return
}
return
}
func (b *Navbar) drawToggleButton(ctx context.Context, _w io.Writer) (err error) {
if _, err = io.WriteString(_w, ` <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#`); err != nil {
return
}
if _, err = io.WriteString(_w, b.ID()); err != nil {
return
}
if _, err = io.WriteString(_w, `_collapse" aria-controls="`); err != nil {
return
}
if _, err = io.WriteString(_w, b.ID()); err != nil {
return
}
if _, err = io.WriteString(_w, `_collapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
`); err != nil {
return
}
return
}
func (b *Navbar) drawBrand(ctx context.Context, _w io.Writer) (err error) {
if b.Text() != "" {
if b.brandAnchor == "" {
if _, err = io.WriteString(_w, ` <span class="navbar-brand">`); err != nil {
return
}
b.DrawText(ctx, _w)
if _, err = io.WriteString(_w, `</span>
`); err != nil {
return
}
} else {
if _, err = io.WriteString(_w, `
<a class="navbar-brand" href="`); err != nil {
return
}
if _, err = io.WriteString(_w, b.brandAnchor); err != nil {
return
}
if _, err = io.WriteString(_w, `">`); err != nil {
return
}
b.DrawText(ctx, _w)
if _, err = io.WriteString(_w, `</a>
`); err != nil {
return
}
}
} else { // draw a blank brand so toggler placement still works
if _, err = io.WriteString(_w, `
<a class="navbar-brand" href="#"> </a>
`); err != nil {
return
}
}
return
}
func (b *Navbar) drawToggleAndBrand(ctx context.Context, _w io.Writer) (err error) {
switch b.brandLocation {
case NavbarCollapsedBrandLeft:
if err = b.drawBrand(ctx, _w); err != nil {
return
}
if err = b.drawToggleButton(ctx, _w); err != nil {
return
}
case NavbarCollapsedBrandRight:
if err = b.drawToggleButton(ctx, _w); err != nil {
return
}
if err = b.drawBrand(ctx, _w); err != nil {
return
}
case NavbarCollapsedBrandHidden:
if err = b.drawToggleButton(ctx, _w); err != nil {
return
}
}
return
}