382 lines
8.4 KiB
Go
382 lines
8.4 KiB
Go
|
// Code generated by templ@(devel) DO NOT EDIT.
|
||
|
|
||
|
package inlinevalidation
|
||
|
|
||
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||
|
|
||
|
import "github.com/a-h/templ"
|
||
|
import "context"
|
||
|
import "io"
|
||
|
import "bytes"
|
||
|
|
||
|
// GoExpression
|
||
|
import "examples/shared"
|
||
|
|
||
|
func demo() templ.Component {
|
||
|
return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) {
|
||
|
templBuffer, templIsBuffer := w.(*bytes.Buffer)
|
||
|
if !templIsBuffer {
|
||
|
templBuffer = templ.GetBuffer()
|
||
|
defer templ.ReleaseBuffer(templBuffer)
|
||
|
}
|
||
|
ctx = templ.InitializeContext(ctx)
|
||
|
var_1 := templ.GetChildren(ctx)
|
||
|
if var_1 == nil {
|
||
|
var_1 = templ.NopComponent
|
||
|
}
|
||
|
ctx = templ.ClearChildren(ctx)
|
||
|
// Element (standard)
|
||
|
_, err = templBuffer.WriteString("<form")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element Attributes
|
||
|
_, err = templBuffer.WriteString(" hx-post=\"/inline-validation/contact\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(">")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// TemplElement
|
||
|
err = inp(fields["email"], "email", "", nil).Render(ctx, templBuffer)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// TemplElement
|
||
|
err = inp(fields["firstName"], "firstName", "", nil).Render(ctx, templBuffer)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// TemplElement
|
||
|
err = inp(fields["lastName"], "lastName", "", nil).Render(ctx, templBuffer)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element (standard)
|
||
|
_, err = templBuffer.WriteString("<div")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element Attributes
|
||
|
_, err = templBuffer.WriteString(" class=\"field\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(">")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element (standard)
|
||
|
_, err = templBuffer.WriteString("<div")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element Attributes
|
||
|
_, err = templBuffer.WriteString(" class=\"control\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(">")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element (standard)
|
||
|
_, err = templBuffer.WriteString("<button")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element Attributes
|
||
|
_, err = templBuffer.WriteString(" class=\"button is-link\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(">")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Text
|
||
|
var_2 := `Submit`
|
||
|
_, err = templBuffer.WriteString(var_2)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("</button>")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("</div>")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("</div>")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("</form>")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
if !templIsBuffer {
|
||
|
_, err = io.Copy(w, templBuffer)
|
||
|
}
|
||
|
return err
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func inp(f field, name, value string, validation error) templ.Component {
|
||
|
return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) {
|
||
|
templBuffer, templIsBuffer := w.(*bytes.Buffer)
|
||
|
if !templIsBuffer {
|
||
|
templBuffer = templ.GetBuffer()
|
||
|
defer templ.ReleaseBuffer(templBuffer)
|
||
|
}
|
||
|
ctx = templ.InitializeContext(ctx)
|
||
|
var_3 := templ.GetChildren(ctx)
|
||
|
if var_3 == nil {
|
||
|
var_3 = templ.NopComponent
|
||
|
}
|
||
|
ctx = templ.ClearChildren(ctx)
|
||
|
// Element (standard)
|
||
|
_, err = templBuffer.WriteString("<div")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element Attributes
|
||
|
_, err = templBuffer.WriteString(" hx-target=\"this\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(" hx-swap=\"outerHTML\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(" class=\"field\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(">")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element (standard)
|
||
|
_, err = templBuffer.WriteString("<label")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element Attributes
|
||
|
_, err = templBuffer.WriteString(" class=\"label\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(">")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// StringExpression
|
||
|
var var_4 string = f.text
|
||
|
_, err = templBuffer.WriteString(templ.EscapeString(var_4))
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("</label>")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element (standard)
|
||
|
_, err = templBuffer.WriteString("<div")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element Attributes
|
||
|
_, err = templBuffer.WriteString(" class=\"control\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(">")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element (void)
|
||
|
_, err = templBuffer.WriteString("<input")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element Attributes
|
||
|
_, err = templBuffer.WriteString(" class=\"input\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
if validation != nil {
|
||
|
// Element Attributes
|
||
|
_, err = templBuffer.WriteString(" class=\"is-danger\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(" name=")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(templ.EscapeString(name))
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(" value=")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(templ.EscapeString(value))
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(" hx-post=")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(templ.EscapeString("/inline-validation/validate/"+name))
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(">")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("</div>")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// If
|
||
|
if validation != nil {
|
||
|
// Element (standard)
|
||
|
_, err = templBuffer.WriteString("<p")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element Attributes
|
||
|
_, err = templBuffer.WriteString(" class=\"help is-danger\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(">")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// StringExpression
|
||
|
var var_5 string = validation.Error()
|
||
|
_, err = templBuffer.WriteString(templ.EscapeString(var_5))
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("</p>")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("</div>")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
if !templIsBuffer {
|
||
|
_, err = io.Copy(w, templBuffer)
|
||
|
}
|
||
|
return err
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func Index() templ.Component {
|
||
|
return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) {
|
||
|
templBuffer, templIsBuffer := w.(*bytes.Buffer)
|
||
|
if !templIsBuffer {
|
||
|
templBuffer = templ.GetBuffer()
|
||
|
defer templ.ReleaseBuffer(templBuffer)
|
||
|
}
|
||
|
ctx = templ.InitializeContext(ctx)
|
||
|
var_6 := templ.GetChildren(ctx)
|
||
|
if var_6 == nil {
|
||
|
var_6 = templ.NopComponent
|
||
|
}
|
||
|
ctx = templ.ClearChildren(ctx)
|
||
|
// TemplElement
|
||
|
var_7 := templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) {
|
||
|
templBuffer, templIsBuffer := w.(*bytes.Buffer)
|
||
|
if !templIsBuffer {
|
||
|
templBuffer = templ.GetBuffer()
|
||
|
defer templ.ReleaseBuffer(templBuffer)
|
||
|
}
|
||
|
// Element (standard)
|
||
|
_, err = templBuffer.WriteString("<h2")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Element Attributes
|
||
|
_, err = templBuffer.WriteString(" class=\"title\"")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString(">")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Text
|
||
|
var_8 := `Inline Validation`
|
||
|
_, err = templBuffer.WriteString(var_8)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = templBuffer.WriteString("</h2>")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// Whitespace (normalised)
|
||
|
_, err = templBuffer.WriteString(` `)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// TemplElement
|
||
|
err = demo().Render(ctx, templBuffer)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
if !templIsBuffer {
|
||
|
_, err = io.Copy(w, templBuffer)
|
||
|
}
|
||
|
return err
|
||
|
})
|
||
|
err = shared.Layout("Inline Validation").Render(templ.WithChildren(ctx, var_7), templBuffer)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
if !templIsBuffer {
|
||
|
_, err = io.Copy(w, templBuffer)
|
||
|
}
|
||
|
return err
|
||
|
})
|
||
|
}
|
||
|
|