Files
nebula/pkg/wa/include_templ.go

300 lines
10 KiB
Go
Raw Normal View History

2026-01-01 14:41:31 -05:00
// Code generated by templ - DO NOT EDIT.
2026-01-01 20:49:44 -05:00
// templ: version: v0.3.960
2026-01-01 14:41:31 -05:00
// 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: <wa-include>
// 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, "<wa-include")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Src != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " src=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(props.Src)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/include.templ`, Line: 116, Col: 18}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Mode != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " mode=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(props.Mode)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/include.templ`, Line: 119, Col: 20}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.AllowScripts {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " allow-scripts")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnLoad != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " x-on:wa-load=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnLoad)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/include.templ`, Line: 125, Col: 30}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnIncludeError != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " x-on:wa-include-error=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnIncludeError)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/include.templ`, Line: 128, Col: 47}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templ.RenderAttributes(ctx, templ_7745c5c3_Buffer, props.Attrs)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, ">")
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, "</wa-include>")
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