1
0
Fork 0
mirror of https://github.com/imjasonh/html synced 2026-07-12 10:49:17 +00:00
html/generated_menu.go

38 lines
851 B
Go
Raw Normal View History

package html
// MenuElement represents the <menu> HTML element.
type MenuElement[C HTMLContent] basicElement[C]
// Menu creates a new <menu> element.
func Menu(children ...HTMLContent) *MenuElement[HTMLContent] {
return &MenuElement[HTMLContent]{
tagName: "menu",
content: children,
}
}
// Render returns the HTML string representation.
func (e *MenuElement[C]) Render() string {
return (*basicElement[C])(e).Render()
}
// Attr sets an arbitrary attribute as an escape hatch.
func (e *MenuElement[C]) Attr(key, value string) *MenuElement[C] {
e.attributes = append(e.attributes, Attribute{Key: key, Value: value})
return e
}
// Compact sets the compact attribute.
func (e *MenuElement[C]) Compact(v bool) *MenuElement[C] {
if v {
e.attributes = append(e.attributes, Attribute{Key: "compact", Value: "compact"})
}
return e
}