Added Data attribute function

This commit is contained in:
Brandon Dyck 2019-03-21 21:58:23 -06:00
parent 328e865231
commit c9d9cc59bc
2 changed files with 9 additions and 1 deletions

View File

@ -12,7 +12,7 @@ func main() {
h.Div()(
h.Img(h.Src("./me.jpg"), h.Id("profile-photo")),
h.Text("hello hatmill!"),
h.Div(h.Disabled())(),
h.Div(h.Disabled(), h.Data("coolness", "awesome"))(),
),
),
)

View File

@ -122,3 +122,11 @@ func WriteDocument(w io.Writer, root *ParentElement) (n int64, err error) {
n += nroot
return
}
// Data creates an attribute of the form "data-suffix='value'".
func Data(suffix, value string) Attrib {
return Attrib{
Key: "data-" + suffix,
Value: value,
}
}