From d41c4e5a85362dec7844a9093b43720eb0e70e72 Mon Sep 17 00:00:00 2001 From: Markus Wüstenberg Date: Tue, 22 Dec 2020 11:46:49 +0100 Subject: Add data- attribute helper (#61) Fixes #49.--- html/attributes.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'html/attributes.go') 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) } -- cgit 1.4.1