-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhtml5_test.go
More file actions
58 lines (50 loc) · 1.09 KB
/
html5_test.go
File metadata and controls
58 lines (50 loc) · 1.09 KB
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
package html5_test
import (
"testing"
h "github.com/gowade/html5"
)
type ToggleAll struct{}
type ToggleOne struct{ i int }
type EditOne struct{ i int }
type RemoveOne struct{ i int }
type Todo struct {
Active bool
Title string
Content string
El h.DOMElement
}
type App struct {
Todos []Todo
}
func (t App) Render() h.Node {
return h.Div().C(
h.Div().ID("main").Hidden(len(t.Todos) == 0).C(
h.Input().ID("toggle-all").Type("checkbox").OnClick(&ToggleAll{}),
h.Label().For("toggle-all").T("Mark all as complete"),
h.UL().ID("todo-list").L(func(l *h.L) {
for i, todo := range t.Todos {
if !todo.Active {
continue
}
l.LI().C(
h.Div().Class("view").C(
h.Input().
Class("toggle").
Type("checkbox").
OnClick(&ToggleOne{i}),
h.Label().OnDblClick(&EditOne{i}).T(todo.Title),
h.Button().Class("destroy").OnClick(&RemoveOne{i}),
),
h.Form().C(
h.Input().Class("edit").
Value(todo.Content).
Ref(&todo.El),
),
)
}
}),
),
)
}
func TestHInterface(t *testing.T) {
}