2 releases
0.1.1 | Jul 15, 2024 |
---|---|
0.1.0 | Jul 15, 2024 |
#604 in Procedural macros
25 downloads per month
11KB
224 lines
bloom-rsx
Essentially, bloom-rsx implements rsx in a way that it just calls a builder-pattern based on the builder-pattern crate.
Tags
Lower-case tags will be transformed to calls to a tag
function that must be in scope (bloom-html provides one for HtmlNode
s):
rsx!(<div id="foo" on_click=|| {} />)
will be transformed into (the equivalent of)
tag("div")
.attr("id", "foo")
.on("click", || {})
.build()
.into()
Children
Children are passed after building the tag itself:
rsx!(<div><span /></div>)
is transformed to
tag("div")
.build()
.children(vec![
tag("span").build().into()
])
Text
Text is just cast to the target node type using into:
rsx!(<div>"foobar"</div>)
becomes
tag("div")
.build()
.children(vec![
"foobar".into()
])
Components
Uppercase tags are transformed to a builder pattern:
rsx!(<MyComponent foo="bar"><div /></MyComponent>)
becomes
MyComponent::new()
.foo("bar")
.children(vec![
tag("div").build().into()
])
.build()
.into()
Dependencies
~1.5MB
~36K SLoC