-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunorderedlist.go
55 lines (45 loc) · 1015 Bytes
/
unorderedlist.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
package carbon
import "io"
type unorderedList struct {
attrs []Attr
children any
nested bool
expressive bool
}
var _ Component = (*unorderedList)(nil)
func UnorderedList(children ...any) *unorderedList {
return &unorderedList{
attrs: nil,
children: children,
nested: false,
expressive: false,
}
}
func (u *unorderedList) Attr(name string, value string) *unorderedList {
u.attrs = append(u.attrs, Attr{name, value})
return u
}
func (u *unorderedList) Nested(nested bool) *unorderedList {
u.nested = nested
return u
}
func (u *unorderedList) Expressive(expressive bool) *unorderedList {
u.expressive = expressive
return u
}
func (u *unorderedList) Render(w io.Writer) {
w.Write([]byte(`<ul class="bx--list--unordered`))
if u.nested {
w.Write([]byte(` bx--list--nested`))
}
if u.expressive {
w.Write([]byte(` bx--list--expressive`))
}
w.Write([]byte(`"`))
renderAttrs(w, u.attrs)
w.Write([]byte(`>`))
{
renderAny(w, u.children)
}
w.Write([]byte(`</ul>`))
}