about summary refs log tree commit diff stats
path: root/html/attributes.go
diff options
context:
space:
mode:
authorMarkus Wüstenberg2024-06-06 12:43:15 +0200
committerGitHub2024-06-06 12:43:15 +0200
commit81b2d6a9e39ff8859400bfa806cb3e712049615c (patch)
treed986529c8f6cb462f61a1057f48f93230938a933 /html/attributes.go
parentd944acd39fd6c987ea3cdd57c2cec525e918425e (diff)
parent0b85f722038e0cc6cc7b66b7d0a704d845b614db (diff)
downloadgomponents-81b2d6a9e39ff8859400bfa806cb3e712049615c.tar.lz
gomponents-81b2d6a9e39ff8859400bfa806cb3e712049615c.tar.zst
gomponents-81b2d6a9e39ff8859400bfa806cb3e712049615c.zip
Deprecate DataAttr, StyleAttr, TitleAttr, FormEl (#174)
This change addresses #170 by deprecating some HTML helpers in favor of
using one of the styles as a main one, selected based on what I think is
the main use case.

- For `Data`, it's the attribute. I don't see much use of the `<data>`
element in the wild.
- For `Style`, it's the attribute. The `style` attribute is everywhere,
the `<style>` element is perhaps less so (but not much). This was the
hardest one to decide.
- For `Title`, it's the attribute. The `<title>` element only shows up
once per document.
- For `Form`, it's the element. I haven't seen much use of the `form`
attribute in the wild.

I know this is arguably not a "consistent" approach, but I think it
makes for a much nicer API, simply because the most-used option will not
be a suffixed version.
Diffstat (limited to 'html/attributes.go')
-rw-r--r--html/attributes.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/html/attributes.go b/html/attributes.go
index 8988ab3..0bc5268 100644
--- a/html/attributes.go
+++ b/html/attributes.go
@@ -109,7 +109,14 @@ func Content(v string) g.Node {
 	return g.Attr("content", v)
 }
 
+// Data attributes automatically have their name prefixed with "data-".
+func Data(name, v string) g.Node {
+	return g.Attr("data-"+name, v)
+}
+
 // DataAttr attributes automatically have their name prefixed with "data-".
+//
+// Deprecated: Use [Data] instead.
 func DataAttr(name, v string) g.Node {
 	return g.Attr("data-"+name, v)
 }
@@ -214,6 +221,11 @@ func Step(v string) g.Node {
 	return g.Attr("step", v)
 }
 
+func Style(v string) g.Node {
+	return g.Attr("style", v)
+}
+
+// Deprecated: Use [Style] instead.
 func StyleAttr(v string) g.Node {
 	return g.Attr("style", v)
 }
@@ -226,6 +238,11 @@ func Target(v string) g.Node {
 	return g.Attr("target", v)
 }
 
+func Title(v string) g.Node {
+	return g.Attr("title", v)
+}
+
+// Deprecated: Use [Title] instead.
 func TitleAttr(v string) g.Node {
 	return g.Attr("title", v)
 }