diff options
author | Markus Wüstenberg | 2020-12-22 11:46:49 +0100 |
---|---|---|
committer | GitHub | 2020-12-22 11:46:49 +0100 |
commit | d41c4e5a85362dec7844a9093b43720eb0e70e72 (patch) | |
tree | 8b9fc056e2721b7403e40852de7abb998dcad993 /html/attributes.go | |
parent | b4918d5a63434e162e5547cf0e8461fcd1931765 (diff) | |
download | gomponents-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.go | 5 |
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) } |