-
Notifications
You must be signed in to change notification settings - Fork 0
/
attributes.go
58 lines (46 loc) · 1.65 KB
/
attributes.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
package html
import "strings"
// Class adds a "class" attribute to the Element
func (element *Element) Class(values ...string) *Element {
return element.Attr("class", strings.Join(values, " "))
}
// For adds a "for" attribute to the Element
func (element *Element) For(value string) *Element {
return element.Attr("for", value)
}
// Data adds a "data-" attribute to the Element
func (element *Element) Data(name string, value string) *Element {
return element.Attr("data-"+name, value)
}
// ID adds an "id" attribute to the Element
func (element *Element) ID(value string) *Element {
return element.Attr("id", value)
}
// Label adds a "label" attribute to the Element
func (element *Element) Label(value string) *Element {
return element.Attr("label", value)
}
// List adds a "list" attribute to the Element
func (element *Element) List(value string) *Element {
return element.Attr("list", value)
}
// Name adds a "name" attribute to the Element
func (element *Element) Name(value string) *Element {
return element.Attr("name", value)
}
// Script adds a "data-script" attribute to the Element (for https://hyperscript.org)
func (element *Element) Script(value string) *Element {
return element.Attr("data-script", value)
}
// Script adds a "style" attribute to the Element
func (element *Element) Style(values ...string) *Element {
return element.Attr("style", strings.Join(values, "; "))
}
// Type adds a "type" attribute to the Element
func (element *Element) Type(value string) *Element {
return element.Attr("type", value)
}
// Value adds a "value" attribute to the Element
func (element *Element) Value(value string) *Element {
return element.Attr("value", value)
}