all repos — gomponents @ f9d584c9889276000171046bcc2e32177514f552

HTML components in pure Go

Make NodeFunc and attr implement fmt.Stringer (#6)

Markus Wüstenberg
commit

f9d584c9889276000171046bcc2e32177514f552

parent

e8faab5207e6ed48aef0a6b1ade710dd8fbfadd3

1 file changed, 10 insertions(+), 0 deletions(-)

changed files
M gomponents.gogomponents.go
@@ -25,6 +25,11 @@ func (n NodeFunc) Render() string {
return n() } +// String satisfies fmt.Stringer. +func (n NodeFunc) String() string { + return n.Render() +} + // El creates an element DOM Node with a name and child Nodes. // Use this if no convenience creator exists. func El(name string, children ...Node) NodeFunc {
@@ -90,6 +95,11 @@ if a.value == nil {
return fmt.Sprintf(" %v", a.name) } return fmt.Sprintf(` %v="%v"`, a.name, *a.value) +} + +// String satisfies fmt.Stringer. +func (a attr) String() string { + return a.Render() } // Text creates a text DOM Node that Renders the escaped string t.