diff --git a/examples/hello.templ b/examples/hello.templ deleted file mode 100644 index bc86f8e..0000000 --- a/examples/hello.templ +++ /dev/null @@ -1,45 +0,0 @@ -package main - -script log(s string) { - console.log(s) -} - -templ hello(name string) { -
text
- @headerTemplate("Hayden") -} - -templ page2() { -- if 5 == 5 { - "five is five" - } -
- @component("testid-123") -} - -templ spread(attrs templ.Attributes) { -- Text -
-} diff --git a/examples/hello_templ.go b/examples/hello_templ.go deleted file mode 100644 index 1a745c2..0000000 --- a/examples/hello_templ.go +++ /dev/null @@ -1,296 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.3.865 -package main - -//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" - -func log(s string) templ.ComponentScript { - return templ.ComponentScript{ - Name: `__templ_log_bfa8`, - Function: `function __templ_log_bfa8(s){console.log(s) -}`, - Call: templ.SafeScript(`__templ_log_bfa8`, s), - CallInline: templ.SafeScriptInline(`__templ_log_bfa8`, s), - } -} - -func hello(name string) 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, "text
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = headerTemplate("Hayden").Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return nil - }) -} - -func page2() 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_Var10 := templ.GetChildren(ctx) - if templ_7745c5c3_Var10 == nil { - templ_7745c5c3_Var10 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - if 5 == 5 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "\"five is five\"") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = component("testid-123").Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return nil - }) -} - -func spread(attrs templ.Attributes) 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_Var11 := templ.GetChildren(ctx) - if templ_7745c5c3_Var11 == nil { - templ_7745c5c3_Var11 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "Text
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return nil - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/examples/main.go b/examples/main.go deleted file mode 100644 index 3b9a6d1..0000000 --- a/examples/main.go +++ /dev/null @@ -1,19 +0,0 @@ -package main - -import ( - "fmt" - "net/http" - - "github.com/a-h/templ" -) - -func main() { - component := page2() - btn := button("Click me") - - http.Handle("/", templ.Handler(component)) - http.Handle("/button", templ.Handler(btn)) - - fmt.Println("Listening on :3000") - http.ListenAndServe(":3000", nil) -} diff --git a/internal/templates/components/navbar.templ b/internal/templates/components/navbar.templ index 3d0ad43..9b150b5 100644 --- a/internal/templates/components/navbar.templ +++ b/internal/templates/components/navbar.templ @@ -3,96 +3,94 @@ package components import "strings" templ hamburgerMenu() { - - - + } + + } templ navLink(current, name, url string) { - - { name } - + + { name } + } templ dropdownLink(name, url string) { - - { name } - + + { name } + } templ listIcon(current, name, url string) { - - - + + + } templ Navbar(current string) { - + } diff --git a/internal/templates/components/navbar_templ.go b/internal/templates/components/navbar_templ.go index d09650b..0273e59 100644 --- a/internal/templates/components/navbar_templ.go +++ b/internal/templates/components/navbar_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.865 +// templ: version: v0.3.898 package components //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -31,7 +31,7 @@ func hamburgerMenu() templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "