Releases: maragudk/gomponents
Generic Map
Map
function has been updated for Go 1.18 onwards, where the function signature is changed from
func Map(length int, cb func(i int) Node) []Node
to
func Map[T any](ts []T, cb func(T) Node) []Node
This should make it slightly easier to map slices of whatever type you're using to HTML components.
Update doc comments
This is a tiny release to update some doc comments.
Add http package for http handler glory
This release adds the http
package, with defines a Handler
and an Adapt
function, which makes it easy to use gomponents with net/http
handlers.
assert
package has been moved to be internal only. No other breaking changes.
Add srcset and loading attributes
Useful on picture
and img
elements. Contributed by @averageflow, thank you! 😎
Add the video element
This release adds the video
element and loop
, muted
, playsinline
, poster
attributes.
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video for the specs.
Escape those attribute values!
v0.17.0 brings a security update, where the library now makes sure to escape attribute values. So feel free to pass user-generated values to Attr
now. Special thanks to @philippta for reporting and guidance. 😎
Also, there are documentation updates, so there should be runnable examples on godoc soon.
Also, two new helper components made it into the components
package: LinkStylesheet
and LinkPreload
. Enjoy!
Streamline all the elements
html
package now take just Node
s as children. No more text strings as the first argument for certain elements like h1
, em
, and many more. This makes the API the same for all element helper functions. (Except Doctype
, which isn't really an element but a document prefix.)
New: The svg
package has begun. It provides helper functions for SVG elements for inlining into HTML documents.
Expose only the Node interface
Node
interface instead of NodeFunc
. The latter is now more or less an implementation detail. For most users of the API, this change will probably not be noticeable.
Add data- attributes
data-
attribute helper. Therefore, the Data
element helper has been renamed to DataEl
.
Conditional nodes and aria attributes
This release adds the If
helper function, to conditionally add nodes inline, as well as aria-
and role
attributes.