mirror of
https://github.com/imjasonh/html
synced 2026-07-08 17:07:10 +00:00
Initial commit
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
commit
01c7432c71
72 changed files with 6192 additions and 0 deletions
67
generated_source.go
Normal file
67
generated_source.go
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
package html
|
||||
|
||||
// SourceElement represents the <source> HTML element.
|
||||
|
||||
type SourceElement basicElement[HTMLContent]
|
||||
|
||||
|
||||
// Source creates a new <source> element.
|
||||
func Source() *SourceElement {
|
||||
return &SourceElement{
|
||||
tagName: "source",
|
||||
isVoid: true,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Render returns the HTML string representation.
|
||||
func (e *SourceElement) Render() string {
|
||||
return (*basicElement[HTMLContent])(e).Render()
|
||||
}
|
||||
|
||||
// Attr sets an arbitrary attribute as an escape hatch.
|
||||
func (e *SourceElement) Attr(key, value string) *SourceElement {
|
||||
e.attributes = append(e.attributes, Attribute{Key: key, Value: value})
|
||||
return e
|
||||
}
|
||||
|
||||
|
||||
// Media sets the media attribute.
|
||||
func (e *SourceElement) Media(v string) *SourceElement {
|
||||
e.attributes = append(e.attributes, Attribute{Key: "media", Value: v})
|
||||
return e
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Sizes sets the sizes attribute.
|
||||
func (e *SourceElement) Sizes(v string) *SourceElement {
|
||||
e.attributes = append(e.attributes, Attribute{Key: "sizes", Value: v})
|
||||
return e
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Src sets the src attribute.
|
||||
func (e *SourceElement) Src(v string) *SourceElement {
|
||||
e.attributes = append(e.attributes, Attribute{Key: "src", Value: v})
|
||||
return e
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Srcset sets the srcset attribute.
|
||||
func (e *SourceElement) Srcset(v string) *SourceElement {
|
||||
e.attributes = append(e.attributes, Attribute{Key: "srcset", Value: v})
|
||||
return e
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Type sets the type attribute.
|
||||
func (e *SourceElement) Type(v string) *SourceElement {
|
||||
e.attributes = append(e.attributes, Attribute{Key: "type", Value: v})
|
||||
return e
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue