From 7dc188647b8e4b19545b57e0f97a8dbf9a4a730e Mon Sep 17 00:00:00 2001 From: Adrian Hesketh Date: Sat, 22 May 2021 14:12:20 +0100 Subject: [PATCH] remove the name from the template output, fixes #7 --- example/posts_templ.go | 4 ++-- generator/generator.go | 4 ++-- generator/test-call/template_templ.go | 4 ++-- generator/test-for/template_templ.go | 2 +- generator/test-html/template_templ.go | 2 +- generator/test-if/template_templ.go | 2 +- generator/test-ifelse/template_templ.go | 2 +- generator/test-string/template_templ.go | 2 +- generator/test-switch/template_templ.go | 2 +- generator/test-switchdefault/template_templ.go | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/example/posts_templ.go b/example/posts_templ.go index a71520843..17fb43df3 100644 --- a/example/posts_templ.go +++ b/example/posts_templ.go @@ -6,7 +6,7 @@ import "github.com/a-h/templ" import "context" import "io" -func postsTemplate(posts []Post) (t templ.Component) { +func postsTemplate(posts []Post) templ.Component { return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) { for _, p := range posts { err = postTemplate(p).Render(ctx, w) @@ -18,7 +18,7 @@ func postsTemplate(posts []Post) (t templ.Component) { }) } -func postTemplate(post Post) (t templ.Component) { +func postTemplate(post Post) templ.Component { return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) { _, err = io.WriteString(w, "
") if err != nil { diff --git a/generator/generator.go b/generator/generator.go index 8ba7717fa..ccd3b4d77 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -175,8 +175,8 @@ func (g *generator) writeTemplate(t templ.Template) error { return err } g.sourceMap.Add(t.Parameters, r) - // ) (t templ.Component error) { - if _, err = g.w.Write(") (t templ.Component) {\n"); err != nil { + // ) templ.Component { + if _, err = g.w.Write(") templ.Component {\n"); err != nil { return err } indentLevel++ diff --git a/generator/test-call/template_templ.go b/generator/test-call/template_templ.go index 41d8f6849..a17661771 100644 --- a/generator/test-call/template_templ.go +++ b/generator/test-call/template_templ.go @@ -6,7 +6,7 @@ import "github.com/a-h/templ" import "context" import "io" -func personTemplate(p person) (t templ.Component) { +func personTemplate(p person) templ.Component { return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) { _, err = io.WriteString(w, "
") if err != nil { @@ -72,7 +72,7 @@ func personTemplate(p person) (t templ.Component) { }) } -func email(s string) (t templ.Component) { +func email(s string) templ.Component { return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) { _, err = io.WriteString(w, "
") if err != nil { diff --git a/generator/test-for/template_templ.go b/generator/test-for/template_templ.go index 6af3e3ed6..8f6e69de5 100644 --- a/generator/test-for/template_templ.go +++ b/generator/test-for/template_templ.go @@ -6,7 +6,7 @@ import "github.com/a-h/templ" import "context" import "io" -func render(items []string) (t templ.Component) { +func render(items []string) templ.Component { return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) { for _, item := range items { _, err = io.WriteString(w, "
") diff --git a/generator/test-html/template_templ.go b/generator/test-html/template_templ.go index 257ca9261..b497fe1ab 100644 --- a/generator/test-html/template_templ.go +++ b/generator/test-html/template_templ.go @@ -6,7 +6,7 @@ import "github.com/a-h/templ" import "context" import "io" -func render(p person) (t templ.Component) { +func render(p person) templ.Component { return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) { _, err = io.WriteString(w, "
") if err != nil { diff --git a/generator/test-if/template_templ.go b/generator/test-if/template_templ.go index cbd6b8c53..2d7a34546 100644 --- a/generator/test-if/template_templ.go +++ b/generator/test-if/template_templ.go @@ -6,7 +6,7 @@ import "github.com/a-h/templ" import "context" import "io" -func render(d data) (t templ.Component) { +func render(d data) templ.Component { return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) { if d.IsTrue() { _, err = io.WriteString(w, templ.EscapeString("True")) diff --git a/generator/test-ifelse/template_templ.go b/generator/test-ifelse/template_templ.go index 3709114fd..625688b9b 100644 --- a/generator/test-ifelse/template_templ.go +++ b/generator/test-ifelse/template_templ.go @@ -6,7 +6,7 @@ import "github.com/a-h/templ" import "context" import "io" -func render(d data) (t templ.Component) { +func render(d data) templ.Component { return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) { if d.IsTrue() { _, err = io.WriteString(w, templ.EscapeString("True")) diff --git a/generator/test-string/template_templ.go b/generator/test-string/template_templ.go index 55476d5fe..1e03fe8b1 100644 --- a/generator/test-string/template_templ.go +++ b/generator/test-string/template_templ.go @@ -6,7 +6,7 @@ import "github.com/a-h/templ" import "context" import "io" -func render(s string) (t templ.Component) { +func render(s string) templ.Component { return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) { _, err = io.WriteString(w, templ.EscapeString(s)) if err != nil { diff --git a/generator/test-switch/template_templ.go b/generator/test-switch/template_templ.go index 6baa0594c..eec7a4011 100644 --- a/generator/test-switch/template_templ.go +++ b/generator/test-switch/template_templ.go @@ -6,7 +6,7 @@ import "github.com/a-h/templ" import "context" import "io" -func render(input string) (t templ.Component) { +func render(input string) templ.Component { return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) { switch input { case "a": diff --git a/generator/test-switchdefault/template_templ.go b/generator/test-switchdefault/template_templ.go index bde2e13c4..af43664bc 100644 --- a/generator/test-switchdefault/template_templ.go +++ b/generator/test-switchdefault/template_templ.go @@ -6,7 +6,7 @@ import "github.com/a-h/templ" import "context" import "io" -func template(input string) (t templ.Component) { +func template(input string) templ.Component { return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) { switch input { case "a":