Repository: maragudk/gomponents
Pull request #192 (2024-08-18 07:03:15)

Add `cite` attribute
It can appear in a `<blockquote>`.

- Closes https://github.com/maragudk/gomponents/issues/189

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/maragudk/gomponents/pull/192?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 100.00%. Comparing base [(`033f6ac`)](https://app.codecov.io/gh/maragudk/gomponents/commit/033f6ac3c36da0e95882d2e00b8cdd54468d3050?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk) to head [(`f3a202e`)](https://app.codecov.io/gh/maragudk/gomponents/commit/f3a202e4609c61fb4c6eb023cfb8cac83e80e57c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk).

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff            @@
##              main      #192   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9         9           
  Lines          534       538    +4     
=========================================
+ Hits           534       538    +4     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/maragudk/gomponents/pull/192?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=maragudk).

markuswustenberg: Thanks for this @yardenshoham ! 😊

Patch:
diff --git a/README.md b/README.md
index f525c3b..db6097d 100644
--- a/README.md
+++ b/README.md
@@ -145,10 +145,11 @@ For more complete examples, see [the examples directory](examples/).
 
 ### What's up with the specially named elements and attributes?
 
-Unfortunately, there are five main name clashes in HTML elements and attributes, so they need an `El` or `Attr` suffix,
+Unfortunately, there are six main name clashes in HTML elements and attributes, so they need an `El` or `Attr` suffix,
 to be able to co-exist in the same package in Go. I've chosen one or the other based on what I think is the common usage.
 In either case, the less-used variant also exists in the codebase:
 
+- `cite` (`CiteEl`/`Cite`, `CiteAttr` also exists)
 - `data` (`DataEl`/`Data`, `DataAttr` also exists)
 - `form` (`Form`/`FormAttr`, `FormEl` also exists)
 - `label` (`Label`/`LabelAttr`, `LabelEl` also exists)
diff --git a/html/attributes.go b/html/attributes.go
index edaf85e..ccd1cb4 100644
--- a/html/attributes.go
+++ b/html/attributes.go
@@ -101,6 +101,10 @@ func Charset(v string) g.Node {
 	return g.Attr("charset", v)
 }
 
+func CiteAttr(v string) g.Node {
+	return g.Attr("cite", v)
+}
+
 func Class(v string) g.Node {
 	return g.Attr("class", v)
 }
diff --git a/html/elements.go b/html/elements.go
index f676462..32752ea 100644
--- a/html/elements.go
+++ b/html/elements.go
@@ -73,6 +73,11 @@ func Cite(children ...g.Node) g.Node {
 	return g.El("cite", children...)
 }
 
+// Deprecated: Use [Cite] instead.
+func CiteEl(children ...g.Node) g.Node {
+	return Cite(children...)
+}
+
 func Code(children ...g.Node) g.Node {
 	return g.El("code", children...)
 }


Test patch:
diff --git a/html/attributes_test.go b/html/attributes_test.go
index 92ce0d6..3eb0252 100644
--- a/html/attributes_test.go
+++ b/html/attributes_test.go
@@ -49,6 +49,7 @@ func TestSimpleAttributes(t *testing.T) {
 		{Name: "as", Func: As},
 		{Name: "autocomplete", Func: AutoComplete},
 		{Name: "charset", Func: Charset},
+		{Name: "cite", Func: CiteAttr},
 		{Name: "class", Func: Class},
 		{Name: "cols", Func: Cols},
 		{Name: "colspan", Func: ColSpan},
diff --git a/html/elements_test.go b/html/elements_test.go
index 88688f4..00639b9 100644
--- a/html/elements_test.go
+++ b/html/elements_test.go
@@ -45,6 +45,7 @@ func TestSimpleElements(t *testing.T) {
 		{Name: "canvas", Func: Canvas},
 		{Name: "caption", Func: Caption},
 		{Name: "cite", Func: Cite},
+		{Name: "cite", Func: CiteEl},
 		{Name: "code", Func: Code},
 		{Name: "colgroup", Func: ColGroup},
 		{Name: "data", Func: DataEl},