Skip to content

Commit

Permalink
Add cite attribute (#192)
Browse files Browse the repository at this point in the history
It can appear in a `<blockquote>`.

- Closes #189

Signed-off-by: Yarden Shoham <[email protected]>
  • Loading branch information
yardenshoham authored Aug 19, 2024
1 parent 033f6ac commit aade772
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions html/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions html/attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
5 changes: 5 additions & 0 deletions html/elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}
Expand Down
1 change: 1 addition & 0 deletions html/elements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit aade772

Please sign in to comment.