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 web component elements and slot attribute #235

Merged
merged 4 commits into from
Oct 25, 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
4 changes: 4 additions & 0 deletions html/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ func DataAttr(name, v string) g.Node {
return Data(name, v)
}

func SlotAttr(v string) g.Node {
return g.Attr("slot", v)
}

func For(v string) g.Node {
return g.Attr("for", 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 @@ -84,6 +84,7 @@ func TestSimpleAttributes(t *testing.T) {
{Name: "role", Func: Role},
{Name: "rows", Func: Rows},
{Name: "rowspan", Func: RowSpan},
{Name: "slot", Func: SlotAttr},
{Name: "src", Func: Src},
{Name: "srcset", Func: SrcSet},
{Name: "step", Func: Step},
Expand Down
8 changes: 8 additions & 0 deletions html/elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ func Select(children ...g.Node) g.Node {
return g.El("select", children...)
}

func SlotEl(children ...g.Node) g.Node {
return g.El("slot", children...)
}

func Source(children ...g.Node) g.Node {
return g.El("source", children...)
}
Expand Down Expand Up @@ -296,6 +300,10 @@ func Td(children ...g.Node) g.Node {
return g.El("td", children...)
}

func Template(children ...g.Node) g.Node {
return g.El("template", children...)
}

func Textarea(children ...g.Node) g.Node {
return g.El("textarea", children...)
}
Expand Down
2 changes: 2 additions & 0 deletions html/elements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func TestSimpleElements(t *testing.T) {
{Name: "script", Func: Script},
{Name: "section", Func: Section},
{Name: "select", Func: Select},
{Name: "slot", Func: SlotEl},
{Name: "small", Func: Small},
{Name: "span", Func: Span},
{Name: "strong", Func: Strong},
Expand All @@ -114,6 +115,7 @@ func TestSimpleElements(t *testing.T) {
{Name: "table", Func: Table},
{Name: "tbody", Func: TBody},
{Name: "td", Func: Td},
{Name: "template", Func: Template},
{Name: "textarea", Func: Textarea},
{Name: "tfoot", Func: TFoot},
{Name: "th", Func: Th},
Expand Down
Loading