// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.960 // Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-include package wa //lint:file-ignore SA4006 This context is only used if a nested component is present. import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" 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 func Include(props IncludeProps) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Var1 := templ.GetChildren(ctx) if templ_7745c5c3_Var1 == nil { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } // IncludeFunc renders with a builder function for inline configuration func IncludeFunc(fn func(*IncludeBuilder)) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Var6 := templ.GetChildren(ctx) if templ_7745c5c3_Var6 == nil { templ_7745c5c3_Var6 = templ.NopComponent } ctx = templ.ClearChildren(ctx) b := NewInclude() fn(b) templ_7745c5c3_Var7 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Err = templ_7745c5c3_Var6.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) templ_7745c5c3_Err = Include(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } var _ = templruntime.GeneratedTemplate