// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.960 // Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-format-date 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" ) // Formats a date/time using the specified locale and options. // // Web Awesome component: // FormatDateProps holds all properties for the wa-format-date component type FormatDateProps struct { // The date/time to format. If not set, the current date and time will be used. When passing a string, it's strongly Date string `attr:"date"` // The format for displaying the weekday. // Valid values: "narrow", "short", "long" Weekday string `attr:"weekday"` // The format for displaying the era. // Valid values: "narrow", "short", "long" Era string `attr:"era"` // The format for displaying the year. // Valid values: "numeric", "2-digit" Year string `attr:"year"` // The format for displaying the month. // Valid values: "numeric", "2-digit", "narrow", "short", "long" Month string `attr:"month"` // The format for displaying the day. // Valid values: "numeric", "2-digit" Day string `attr:"day"` // The format for displaying the hour. // Valid values: "numeric", "2-digit" Hour string `attr:"hour"` // The format for displaying the minute. // Valid values: "numeric", "2-digit" Minute string `attr:"minute"` // The format for displaying the second. // Valid values: "numeric", "2-digit" Second string `attr:"second"` // The format for displaying the time. // Valid values: "short", "long" TimeZoneName string `attr:"time-zone-name"` // The time zone to express the time in. TimeZone string `attr:"time-zone"` // The format for displaying the hour. // Valid values: "auto", "12", "24" HourFormat string `attr:"hour-format"` // Events // Slots contains named slot content Slots FormatDateSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // FormatDateBuilder provides a fluent API for constructing FormatDateProps type FormatDateBuilder struct { props FormatDateProps } // NewFormatDate creates a new builder for wa-format-date func NewFormatDate() *FormatDateBuilder { return &FormatDateBuilder{} } // Date sets the date attribute // The date/time to format. If not set, the current date and time will be used. When passing a string, it's strongly func (b *FormatDateBuilder) Date(v string) *FormatDateBuilder { b.props.Date = v return b } // Weekday sets the weekday attribute // The format for displaying the weekday. func (b *FormatDateBuilder) Weekday(v string) *FormatDateBuilder { b.props.Weekday = v return b } // Era sets the era attribute // The format for displaying the era. func (b *FormatDateBuilder) Era(v string) *FormatDateBuilder { b.props.Era = v return b } // Year sets the year attribute // The format for displaying the year. func (b *FormatDateBuilder) Year(v string) *FormatDateBuilder { b.props.Year = v return b } // Month sets the month attribute // The format for displaying the month. func (b *FormatDateBuilder) Month(v string) *FormatDateBuilder { b.props.Month = v return b } // Day sets the day attribute // The format for displaying the day. func (b *FormatDateBuilder) Day(v string) *FormatDateBuilder { b.props.Day = v return b } // Hour sets the hour attribute // The format for displaying the hour. func (b *FormatDateBuilder) Hour(v string) *FormatDateBuilder { b.props.Hour = v return b } // Minute sets the minute attribute // The format for displaying the minute. func (b *FormatDateBuilder) Minute(v string) *FormatDateBuilder { b.props.Minute = v return b } // Second sets the second attribute // The format for displaying the second. func (b *FormatDateBuilder) Second(v string) *FormatDateBuilder { b.props.Second = v return b } // TimeZoneName sets the time-zone-name attribute // The format for displaying the time. func (b *FormatDateBuilder) TimeZoneName(v string) *FormatDateBuilder { b.props.TimeZoneName = v return b } // TimeZone sets the time-zone attribute // The time zone to express the time in. func (b *FormatDateBuilder) TimeZone(v string) *FormatDateBuilder { b.props.TimeZone = v return b } // HourFormat sets the hour-format attribute // The format for displaying the hour. func (b *FormatDateBuilder) HourFormat(v string) *FormatDateBuilder { b.props.HourFormat = v return b } // Attr adds a custom HTML attribute func (b *FormatDateBuilder) Attr(name, value string) *FormatDateBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *FormatDateBuilder) Attrs(attrs templ.Attributes) *FormatDateBuilder { 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 *FormatDateBuilder) Props() FormatDateProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *FormatDateBuilder) Build() FormatDateProps { return b.props } // FormatDate renders the wa-format-date component func FormatDate(props FormatDateProps) 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, 27, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } // FormatDateFunc renders with a builder function for inline configuration func FormatDateFunc(fn func(*FormatDateBuilder)) 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_Var14 := templ.GetChildren(ctx) if templ_7745c5c3_Var14 == nil { templ_7745c5c3_Var14 = templ.NopComponent } ctx = templ.ClearChildren(ctx) b := NewFormatDate() fn(b) templ_7745c5c3_Var15 := 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_Var14.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) templ_7745c5c3_Err = FormatDate(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var15), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } var _ = templruntime.GeneratedTemplate