about summary refs log tree commit diff stats
path: root/gomponents.go
diff options
context:
space:
mode:
authorMarkus Wüstenberg2020-10-29 13:07:22 +0100
committerGitHub2020-10-29 13:07:22 +0100
commitf277d1942e9f2ec1ff4a3bc3c409e864103b506b (patch)
tree24946956b4bcdb137067bb38e0efe553ae2d4d29 /gomponents.go
parent3df42084aed213fc9e760b53b5132da63b1818b7 (diff)
downloadgomponents-f277d1942e9f2ec1ff4a3bc3c409e864103b506b.tar.lz
gomponents-f277d1942e9f2ec1ff4a3bc3c409e864103b506b.tar.zst
gomponents-f277d1942e9f2ec1ff4a3bc3c409e864103b506b.zip
Pass attributes as pointers (#37)
Diffstat (limited to 'gomponents.go')
-rw-r--r--gomponents.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/gomponents.go b/gomponents.go
index ee156b9..e6b89e1 100644
--- a/gomponents.go
+++ b/gomponents.go
@@ -114,9 +114,9 @@ func renderChild(c Node, inside, outside *strings.Builder) {
 func Attr(name string, value ...string) Node {
 	switch len(value) {
 	case 0:
-		return attr{name: name}
+		return &attr{name: name}
 	case 1:
-		return attr{name: name, value: &value[0]}
+		return &attr{name: name, value: &value[0]}
 	default:
 		panic("attribute must be just name or name and value pair")
 	}
@@ -127,19 +127,19 @@ type attr struct {
 	value *string
 }
 
-func (a attr) Render() string {
+func (a *attr) Render() string {
 	if a.value == nil {
 		return fmt.Sprintf(" %v", a.name)
 	}
 	return fmt.Sprintf(` %v="%v"`, a.name, *a.value)
 }
 
-func (a attr) Place() Placement {
+func (a *attr) Place() Placement {
 	return Inside
 }
 
 // String satisfies fmt.Stringer.
-func (a attr) String() string {
+func (a *attr) String() string {
 	return a.Render()
 }