diff options
author | Markus Wüstenberg | 2020-09-18 14:38:09 +0200 |
---|---|---|
committer | GitHub | 2020-09-18 14:38:09 +0200 |
commit | f9d584c9889276000171046bcc2e32177514f552 (patch) | |
tree | a07b241aef821b40b01cb46919966e90b1452d5c /gomponents.go | |
parent | e8faab5207e6ed48aef0a6b1ade710dd8fbfadd3 (diff) | |
download | gomponents-f9d584c9889276000171046bcc2e32177514f552.tar.lz gomponents-f9d584c9889276000171046bcc2e32177514f552.tar.zst gomponents-f9d584c9889276000171046bcc2e32177514f552.zip |
Make NodeFunc and attr implement fmt.Stringer (#6)
Diffstat (limited to 'gomponents.go')
-rw-r--r-- | gomponents.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gomponents.go b/gomponents.go index ab85226..beb13f3 100644 --- a/gomponents.go +++ b/gomponents.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 { @@ -92,6 +97,11 @@ func (a attr) Render() string { 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. func Text(t string) NodeFunc { return func() string { |