// Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-include package wa import ( "github.com/a-h/templ" ) // Includes give you the power to embed external HTML files into the page. // // Web Awesome component: // IncludeProps holds all properties for the wa-include component type IncludeProps struct { // The location of the HTML file to include. Be sure you trust the content you are including as it will be executed as Src string `attr:"src"` // The fetch mode to use. // Valid values: "cors", "no-cors", "same-origin" Mode string `attr:"mode"` // Allows included scripts to be executed. Be sure you trust the content you are including as it will be executed as AllowScripts bool `attr:"allow-scripts"` // Events // Emitted when the included file is loaded. OnLoad string `attr:"x-on:wa-load"` // Emitted when the included file fails to load due to an error. OnIncludeError string `attr:"x-on:wa-include-error"` // Slots contains named slot content Slots IncludeSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // IncludeBuilder provides a fluent API for constructing IncludeProps type IncludeBuilder struct { props IncludeProps } // NewInclude creates a new builder for wa-include func NewInclude() *IncludeBuilder { return &IncludeBuilder{} } // Src sets the src attribute // The location of the HTML file to include. Be sure you trust the content you are including as it will be executed as func (b *IncludeBuilder) Src(v string) *IncludeBuilder { b.props.Src = v return b } // Mode sets the mode attribute // The fetch mode to use. func (b *IncludeBuilder) Mode(v string) *IncludeBuilder { b.props.Mode = v return b } // AllowScripts sets the allow-scripts attribute // Allows included scripts to be executed. Be sure you trust the content you are including as it will be executed as func (b *IncludeBuilder) AllowScripts(v bool) *IncludeBuilder { b.props.AllowScripts = v return b } // OnLoad sets the handler for wa-load event // Emitted when the included file is loaded. func (b *IncludeBuilder) OnLoad(handler string) *IncludeBuilder { b.props.OnLoad = handler return b } // OnIncludeError sets the handler for wa-include-error event // Emitted when the included file fails to load due to an error. func (b *IncludeBuilder) OnIncludeError(handler string) *IncludeBuilder { b.props.OnIncludeError = handler return b } // Attr adds a custom HTML attribute func (b *IncludeBuilder) Attr(name, value string) *IncludeBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *IncludeBuilder) Attrs(attrs templ.Attributes) *IncludeBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } for k, v := range attrs { b.props.Attrs[k] = v } return b } // Props returns the built properties func (b *IncludeBuilder) Props() IncludeProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *IncludeBuilder) Build() IncludeProps { return b.props } // Include renders the wa-include component templ Include(props IncludeProps) { { children... } } // IncludeFunc renders with a builder function for inline configuration templ IncludeFunc(fn func(*IncludeBuilder)) { {{ b := NewInclude(); fn(b) }} @Include(b.Props()) { { children... } } }