mirror of
https://github.com/imjasonh/html
synced 2026-07-07 00:23:26 +00:00
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
35 lines
825 B
Go
35 lines
825 B
Go
package html
|
|
|
|
// DataElement represents the <data> HTML element.
|
|
|
|
type DataElement[C HTMLContent] basicElement[C]
|
|
|
|
|
|
// Data creates a new <data> element.
|
|
func Data(children ...HTMLContent) *DataElement[HTMLContent] {
|
|
return &DataElement[HTMLContent]{
|
|
tagName: "data",
|
|
|
|
content: children,
|
|
}
|
|
}
|
|
|
|
// Render returns the HTML string representation.
|
|
func (e *DataElement[C]) Render() string {
|
|
return (*basicElement[C])(e).Render()
|
|
}
|
|
|
|
// Attr sets an arbitrary attribute as an escape hatch.
|
|
func (e *DataElement[C]) Attr(key, value string) *DataElement[C] {
|
|
e.attributes = append(e.attributes, Attribute{Key: key, Value: value})
|
|
return e
|
|
}
|
|
|
|
|
|
// Value sets the value attribute.
|
|
func (e *DataElement[C]) Value(v string) *DataElement[C] {
|
|
e.attributes = append(e.attributes, Attribute{Key: "value", Value: v})
|
|
return e
|
|
}
|
|
|
|
|