Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cite attribute #192

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading