about summary refs log tree commit diff stats
path: root/gomponents_test.go
Commit message (Collapse)AuthorAgeLines
* Mark the assert test helpers as such (#90)Markus Wüstenberg2021-10-06-1/+1
| | | | | Using `t.Helper()`. Also move the assert package to be internal.
* Add javascript alert onclick handler to Raw example (#82)Markus Wüstenberg2021-06-09-2/+4
| | | Makes for fun XSS testing.
* Add examples in test files (#80)Markus Wüstenberg2021-06-08-0/+56
| | | These show up in godoc.
* Escape Attr values (#77)Markus Wüstenberg2021-05-18-0/+14
| | | | | Because this can be a place of injection if untrusted data is passed, escape all attribute values. Fixes #74.
* Add If helper function (#57)Markus Wüstenberg2020-12-22-0/+12
| | | Used to inline conditional nodes.
* Render correct HTML5 (#44)Markus Wüstenberg2020-11-16-17/+28
| | | | | | | | | Previously, elements of kind void and empty elements generally would be rendered auto-closing (with a final `/` character in the start tag), which is allowed sometimes but arguably wrong. See https://dev.w3.org/html5/spec-LC/syntax.html#end-tags This created problems with for example `textarea` and `script`, which cannot be auto-closing, or the browser renders it wrong. Also clarified in the docs that this library outputs HTML5. Fixes #42.
* Add Map function (#40)Markus Wüstenberg2020-11-02-0/+13
| | | `Map` makes it easier to build lists of elements without having to iterate.
* Render to Writer instead of string (#39)Markus Wüstenberg2020-11-02-37/+44
| | | | | | | The Render function has been changed to take a `Writer` instead of returning a string. This makes it possible to generate documents without having the whole content in memory. This also removes the `gomponents.Write` function, which is now redundant. Furthermore, the `el.Document` function has been changed to only take one child, as multiple children never make sense for it. (It's not even a child, more a sibling.)
* Remove fmt.Sprintf call in attribute Render (#38)Markus Wüstenberg2020-10-29-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Just concatenating the strings is much faster. Before: ``` make benchmark go test -bench=. goos: darwin goarch: amd64 pkg: github.com/maragudk/gomponents BenchmarkAttr/boolean_attributes-8 8194791 139 ns/op BenchmarkAttr/name-value_attributes-8 5143292 229 ns/op PASS ok github.com/maragudk/gomponents 2.841s ``` After: ``` make benchmark go test -bench=. goos: darwin goarch: amd64 pkg: github.com/maragudk/gomponents BenchmarkAttr/boolean_attributes-8 16755404 67.0 ns/op BenchmarkAttr/name-value_attributes-8 10208625 116 ns/op PASS ok github.com/maragudk/gomponents 2.702s ```
* Don't render or error on nil children (#32)Markus Wüstenberg2020-10-23-0/+5
| | | This makes it easier to e.g. conditionally skip a component for rendering.
* Add Group function to group Nodes (#29)Markus Wüstenberg2020-10-22-0/+22
|
* Add space before auto-closing element (#20)Markus Wüstenberg2020-09-24-10/+10
|
* Introduce Placer interface (#18)Markus Wüstenberg2020-09-24-0/+11
| | | | | 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.
* Add Textf function (#17)Markus Wüstenberg2020-09-23-0/+7
| | | Like Text, but calls fmt.Sprintf before rendering.
* Add a test for attr.String (#12)Markus Wüstenberg2020-09-21-0/+9
|
* Add a Write function (#11)Markus Wüstenberg2020-09-21-0/+30
|
* Make NodeFunc and attr implement fmt.Stringer (#6)Markus Wüstenberg2020-09-18-15/+18
|
* Add first implementation of Node, El, Attr, TextMarkus Wüstenberg2020-09-13-0/+75