Introduce Placer interface (#18) When implemented, the `Place` method of the `Placer` interface tells `Render` in `El` where to put a Node. This is relevant for helpers that want to be rendered like attributes, inside the parent element. Fixes the bug where `attr.Classes` was rendered outside the element.
1 file changed, 6 insertions(+), 0 deletions(-)
changed files
M attr/attributes_test.go → attr/attributes_test.go
@@ -3,6 +3,7 @@ import ( "testing" + g "github.com/maragudk/gomponents" "github.com/maragudk/gomponents/assert" "github.com/maragudk/gomponents/attr" )@@ -27,6 +28,11 @@ "hat": true, "partyhat": true, "turtlehat": false, }) + }) + + t.Run("renders as attribute in an element", func(t *testing.T) { + e := g.El("div", attr.Classes{"hat": true}) + assert.Equal(t, `<div class="hat"/>`, e) }) t.Run("also works with fmt", func(t *testing.T) {