Alternative macro for building Html
in Yew.
This example represents the root App
component of a Yew application.
It shows interpolation in text nodes, interpolation in attributes,
multiple nodes in root of the macro, shortened tag closing.
```rust use yew::prelude::*; use yewalthtml::ah;
pub fn App() { let name = "Yew"; let italic_style = "font-style: italic";
ah! {
<h1 style=italic_style>"Hello " name "!"</>
<p>"Welcome to "<code>"yew-alt-html"</>"!"</>
}
} ```
html!
?This crate experiments on creating a macro that would be easier to use.
For this, the html!
syntax
that was a bit cumbersome to use
is replaced by direct usage of values in ah!
.
Following problems should be solved by this crate:
{}
inside tags even when values are simple literals.{}
(mind that shorthand still uses { variable }
).<></>
when using multiple nodes in the macro root.Most html!
syntax
should be supported by the ah!
macro.
If your code does not work by just replacing html!
with ah!
,
submit an issue.
Some syntax is limited (for example, using <
in attributes without an if
).
Suggested solution would be moving complex values into variables before ah!
,
or wrapping values in {}
braces just like you do in html!
.
match
cases
(requires wrapping the tag in ah!
currently), similar to if
.html!
under the hood: adding more checks
(that are currently handled by html!
)
and generating virtual dom manually.