all repos — gomponents @ 6d2fb0eeb15d6b9774f127517d160137251264a4

HTML components in pure Go

Add Group function to group Nodes (#29)

Markus Wüstenberg
commit

6d2fb0eeb15d6b9774f127517d160137251264a4

parent

f2a2b949704e2faa7117dd33aae8da551a4baf8e

1 file changed, 8 insertions(+), 8 deletions(-)

changed files
M el/form.goel/form.go
@@ -13,40 +13,40 @@ }
// Form returns an element with name "form", the given action and method attributes, and the given children. func Form(action, method string, children ...g.Node) g.NodeFunc { - return g.El("form", prepend2(g.Attr("action", action), g.Attr("method", method), children)...) + return g.El("form", g.Attr("action", action), g.Attr("method", method), g.Group(children)) } // Input returns an element with name "input", the given type and name attributes, and the given children. // Note that "type" is a keyword in Go, so the parameter is called typ. func Input(typ, name string, children ...g.Node) g.NodeFunc { - return g.El("input", prepend2(g.Attr("type", typ), g.Attr("name", name), children)...) + return g.El("input", g.Attr("type", typ), g.Attr("name", name), g.Group(children)) } // Label returns an element with name "label", the given for attribute, and the given children. // Note that "for" is a keyword in Go, so the parameter is called forr. func Label(forr string, children ...g.Node) g.NodeFunc { - return g.El("label", prepend(g.Attr("for", forr), children)...) + return g.El("label", g.Attr("for", forr), g.Group(children)) } // Option returns an element with name "option", the given text content and value attribute, and the given children. func Option(text, value string, children ...g.Node) g.NodeFunc { - return g.El("option", prepend2(g.Attr("value", value), g.Text(text), children)...) + return g.El("option", g.Attr("value", value), g.Text(text), g.Group(children)) } // Progress returns an element with name "progress", the given value and max attributes, and the given children. func Progress(value, max float64, children ...g.Node) g.NodeFunc { - return g.El("progress", prepend2( + return g.El("progress", g.Attr("value", fmt.Sprintf("%v", value)), g.Attr("max", fmt.Sprintf("%v", max)), - children)...) + g.Group(children)) } // Select returns an element with name "select", the given name attribute, and the given children. func Select(name string, children ...g.Node) g.NodeFunc { - return g.El("select", prepend(g.Attr("name", name), children)...) + return g.El("select", g.Attr("name", name), g.Group(children)) } // Textarea returns an element with name "textarea", the given name attribute, and the given children. func Textarea(name string, children ...g.Node) g.NodeFunc { - return g.El("textarea", prepend(g.Attr("name", name), children)...) + return g.El("textarea", g.Attr("name", name), g.Group(children)) }