-
Notifications
You must be signed in to change notification settings - Fork 6
/
navbar.tpl.go
executable file
·92 lines (66 loc) · 1.78 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
//** This file was code generated by got. DO NOT EDIT. ***
package control
import (
"bytes"
"context"
)
func (b *Navbar) DrawTemplate(ctx context.Context, buf *bytes.Buffer) (err error) {
b.drawToggleAndBrand(ctx, buf)
buf.WriteString(` <div class="collapse navbar-collapse" id="`)
buf.WriteString(b.ID())
buf.WriteString(`_collapse">
`)
if b.brandLocation == NavbarCollapsedBrandHidden {
b.drawBrand(ctx, buf)
}
buf.WriteString(` `)
{
err := b.DrawChildren(ctx, buf)
if err != nil {
return err
}
}
buf.WriteString(` </div>
`)
return
}
func (b *Navbar) drawToggleButton(ctx context.Context, buf *bytes.Buffer) {
buf.WriteString(` <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#`)
buf.WriteString(b.ID())
buf.WriteString(`_collapse" aria-controls="`)
buf.WriteString(b.ID())
buf.WriteString(`_collapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
`)
}
func (b *Navbar) drawBrand(ctx context.Context, buf *bytes.Buffer) {
if b.Text() != "" {
buf.WriteString(` <a class="navbar-brand" href="`)
if b.headerAnchor == "" {
buf.WriteString(`#`)
} else {
buf.WriteString(b.headerAnchor)
}
buf.WriteString(`">`)
b.DrawText(ctx, buf)
buf.WriteString(`</a>
`)
} else { // draw a blank brand so toggler placement still works
buf.WriteString(`
<a class="navbar-brand" href="#"> </a>
`)
}
}
func (b *Navbar) drawToggleAndBrand(ctx context.Context, buf *bytes.Buffer) {
switch b.brandLocation {
case NavbarCollapsedBrandLeft:
b.drawBrand(ctx, buf)
b.drawToggleButton(ctx, buf)
case NavbarCollapsedBrandRight:
b.drawToggleButton(ctx, buf)
b.drawBrand(ctx, buf)
case NavbarCollapsedBrandHidden:
b.drawToggleButton(ctx, buf)
}
}