diff --git a/example/example.go b/example/example.go index 16a3d2c..8d87d03 100644 --- a/example/example.go +++ b/example/example.go @@ -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"))(), ), ), ) diff --git a/hatmill.go b/hatmill.go index 346de3c..36bd6d8 100644 --- a/hatmill.go +++ b/hatmill.go @@ -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, + } +}