about summary refs log tree commit diff stats
path: root/html/attributes.go
diff options
context:
space:
mode:
authorMarkus Wüstenberg2020-12-22 11:46:49 +0100
committerGitHub2020-12-22 11:46:49 +0100
commitd41c4e5a85362dec7844a9093b43720eb0e70e72 (patch)
tree8b9fc056e2721b7403e40852de7abb998dcad993 /html/attributes.go
parentb4918d5a63434e162e5547cf0e8461fcd1931765 (diff)
downloadgomponents-d41c4e5a85362dec7844a9093b43720eb0e70e72.tar.lz
gomponents-d41c4e5a85362dec7844a9093b43720eb0e70e72.tar.zst
gomponents-d41c4e5a85362dec7844a9093b43720eb0e70e72.zip
Add data- attribute helper (#61)
Fixes #49.
Diffstat (limited to 'html/attributes.go')
-rw-r--r--html/attributes.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/html/attributes.go b/html/attributes.go
index fabfbf0..23559f6 100644
--- a/html/attributes.go
+++ b/html/attributes.go
@@ -81,6 +81,11 @@ func Content(v string) g.Node {
 	return g.Attr("content", v)
 }
 
+// DataAttr attributes automatically have their name prefixed with "data-".
+func DataAttr(name, v string) g.Node {
+	return g.Attr("data-"+name, v)
+}
+
 func For(v string) g.Node {
 	return g.Attr("for", v)
 }