all repos — gomponents @ a76262652b227c95ce140f3698c46f59b79354ac

HTML components in pure Go

Move elements and attributes into html package (#52) This makes it easier to use dot-imports. Also updated the readme and examples with new usage, and move the `Classes` helper into the `components` package.

Markus Wüstenberg
commit

a76262652b227c95ce140f3698c46f59b79354ac

parent

a7e24c6cddaafb98091c3989c9da7779eeba30b5

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

changed files
M attr/attributes_test.gocomponents/attributes_test.go
@@ -1,16 +1,16 @@
-package attr_test +package components_test import ( "testing" g "github.com/maragudk/gomponents" "github.com/maragudk/gomponents/assert" - "github.com/maragudk/gomponents/attr" + c "github.com/maragudk/gomponents/components" ) func TestClasses(t *testing.T) { t.Run("given a map, returns sorted keys from the map with value true", func(t *testing.T) { - assert.Equal(t, ` class="boheme-hat hat partyhat"`, attr.Classes{ + assert.Equal(t, ` class="boheme-hat hat partyhat"`, c.Classes{ "boheme-hat": true, "hat": true, "partyhat": true,
@@ -19,12 +19,12 @@ })
}) t.Run("renders as attribute in an element", func(t *testing.T) { - e := g.El("div", attr.Classes{"hat": true}) + e := g.El("div", c.Classes{"hat": true}) assert.Equal(t, `<div class="hat"></div>`, e) }) t.Run("also works with fmt", func(t *testing.T) { - a := attr.Classes{"hat": true} + a := c.Classes{"hat": true} if a.String() != ` class="hat"` { t.FailNow() }