From 4ecd5ccaf731f3dbc91b2b8b46fc2df0ad1c6e24 Mon Sep 17 00:00:00 2001 From: Brandon Dyck Date: Sun, 24 Mar 2019 20:46:38 -0600 Subject: [PATCH] Removed unneeded pointer from ParentElement receivers --- hatmill.go | 6 ++--- html5/generated.go | 48 ++++++++++++++++++------------------- internal/codegen/codegen.go | 6 ++--- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/hatmill.go b/hatmill.go index 66520ab..14698d8 100644 --- a/hatmill.go +++ b/hatmill.go @@ -78,9 +78,9 @@ type ParentElement struct { Children []Term } -func (e *ParentElement) isHtml() {} +func (e ParentElement) isHtml() {} -func (e *ParentElement) WriteTo(w io.Writer) (n int64, err error) { +func (e ParentElement) WriteTo(w io.Writer) (n int64, err error) { n, err = e.EmptyElement.WriteTo(w) if err != nil { return @@ -110,7 +110,7 @@ func (t Text) WriteTo(w io.Writer) (n int64, err error) { // WriteDocument writes an HTML5 doctype declaration, followed by root. // root should probably be an element. -func WriteDocument(w io.Writer, root *ParentElement) (n int64, err error) { +func WriteDocument(w io.Writer, root ParentElement) (n int64, err error) { err = writeStringsTo(w, &n, "") if err != nil { return diff --git a/html5/generated.go b/html5/generated.go index 1a6a995..4432782 100644 --- a/html5/generated.go +++ b/html5/generated.go @@ -6,9 +6,9 @@ package html5 import "gitlab.codemonkeysoftware.net/b/hatmill" // Body creates a element. -func Body(attribs ...hatmill.Attrib) func(children ...hatmill.Term) *hatmill.ParentElement { - return func(children ...hatmill.Term) *hatmill.ParentElement { - return &hatmill.ParentElement{ +func Body(attribs ...hatmill.Attrib) func(children ...hatmill.Term) hatmill.ParentElement { + return func(children ...hatmill.Term) hatmill.ParentElement { + return hatmill.ParentElement{ EmptyElement: hatmill.EmptyElement{ TagName: "body", Attribs: attribs, @@ -19,9 +19,9 @@ func Body(attribs ...hatmill.Attrib) func(children ...hatmill.Term) *hatmill.Par } // Div creates a
element. -func Div(attribs ...hatmill.Attrib) func(children ...hatmill.Term) *hatmill.ParentElement { - return func(children ...hatmill.Term) *hatmill.ParentElement { - return &hatmill.ParentElement{ +func Div(attribs ...hatmill.Attrib) func(children ...hatmill.Term) hatmill.ParentElement { + return func(children ...hatmill.Term) hatmill.ParentElement { + return hatmill.ParentElement{ EmptyElement: hatmill.EmptyElement{ TagName: "div", Attribs: attribs, @@ -32,9 +32,9 @@ func Div(attribs ...hatmill.Attrib) func(children ...hatmill.Term) *hatmill.Pare } // Head creates a element. -func Head(attribs ...hatmill.Attrib) func(children ...hatmill.Term) *hatmill.ParentElement { - return func(children ...hatmill.Term) *hatmill.ParentElement { - return &hatmill.ParentElement{ +func Head(attribs ...hatmill.Attrib) func(children ...hatmill.Term) hatmill.ParentElement { + return func(children ...hatmill.Term) hatmill.ParentElement { + return hatmill.ParentElement{ EmptyElement: hatmill.EmptyElement{ TagName: "head", Attribs: attribs, @@ -45,9 +45,9 @@ func Head(attribs ...hatmill.Attrib) func(children ...hatmill.Term) *hatmill.Par } // Html creates a element. -func Html(attribs ...hatmill.Attrib) func(children ...hatmill.Term) *hatmill.ParentElement { - return func(children ...hatmill.Term) *hatmill.ParentElement { - return &hatmill.ParentElement{ +func Html(attribs ...hatmill.Attrib) func(children ...hatmill.Term) hatmill.ParentElement { + return func(children ...hatmill.Term) hatmill.ParentElement { + return hatmill.ParentElement{ EmptyElement: hatmill.EmptyElement{ TagName: "html", Attribs: attribs, @@ -66,9 +66,9 @@ func Img(attribs ...hatmill.Attrib) hatmill.EmptyElement { } // Li creates a
  • element. -func Li(attribs ...hatmill.Attrib) func(children ...hatmill.Term) *hatmill.ParentElement { - return func(children ...hatmill.Term) *hatmill.ParentElement { - return &hatmill.ParentElement{ +func Li(attribs ...hatmill.Attrib) func(children ...hatmill.Term) hatmill.ParentElement { + return func(children ...hatmill.Term) hatmill.ParentElement { + return hatmill.ParentElement{ EmptyElement: hatmill.EmptyElement{ TagName: "li", Attribs: attribs, @@ -79,9 +79,9 @@ func Li(attribs ...hatmill.Attrib) func(children ...hatmill.Term) *hatmill.Paren } // Span creates a element. -func Span(attribs ...hatmill.Attrib) func(children ...hatmill.Term) *hatmill.ParentElement { - return func(children ...hatmill.Term) *hatmill.ParentElement { - return &hatmill.ParentElement{ +func Span(attribs ...hatmill.Attrib) func(children ...hatmill.Term) hatmill.ParentElement { + return func(children ...hatmill.Term) hatmill.ParentElement { + return hatmill.ParentElement{ EmptyElement: hatmill.EmptyElement{ TagName: "span", Attribs: attribs, @@ -92,9 +92,9 @@ func Span(attribs ...hatmill.Attrib) func(children ...hatmill.Term) *hatmill.Par } // Title creates a element. -func Title(attribs ...hatmill.Attrib) func(children ...hatmill.Term) *hatmill.ParentElement { - return func(children ...hatmill.Term) *hatmill.ParentElement { - return &hatmill.ParentElement{ +func Title(attribs ...hatmill.Attrib) func(children ...hatmill.Term) hatmill.ParentElement { + return func(children ...hatmill.Term) hatmill.ParentElement { + return hatmill.ParentElement{ EmptyElement: hatmill.EmptyElement{ TagName: "title", Attribs: attribs, @@ -105,9 +105,9 @@ func Title(attribs ...hatmill.Attrib) func(children ...hatmill.Term) *hatmill.Pa } // Ul creates a <ul> element. -func Ul(attribs ...hatmill.Attrib) func(children ...hatmill.Term) *hatmill.ParentElement { - return func(children ...hatmill.Term) *hatmill.ParentElement { - return &hatmill.ParentElement{ +func Ul(attribs ...hatmill.Attrib) func(children ...hatmill.Term) hatmill.ParentElement { + return func(children ...hatmill.Term) hatmill.ParentElement { + return hatmill.ParentElement{ EmptyElement: hatmill.EmptyElement{ TagName: "ul", Attribs: attribs, diff --git a/internal/codegen/codegen.go b/internal/codegen/codegen.go index 5462490..071e13e 100644 --- a/internal/codegen/codegen.go +++ b/internal/codegen/codegen.go @@ -105,9 +105,9 @@ type ElemDef struct { func (def ElemDef) Generate(qualified bool) string { const ( parentTemplate = `// %[1]s creates a <%[2]s> element. - func %[1]s(attribs ...%[3]sAttrib) func(children ...%[3]sTerm) *%[3]sParentElement { - return func(children ...%[3]sTerm) *%[3]sParentElement { - return &%[3]sParentElement{ + func %[1]s(attribs ...%[3]sAttrib) func(children ...%[3]sTerm) %[3]sParentElement { + return func(children ...%[3]sTerm) %[3]sParentElement { + return %[3]sParentElement{ EmptyElement: %[3]sEmptyElement{ TagName: "%[2]s", Attribs: attribs,