#html #proc-macro #react #jsx #html-macro #web-framework #frameworkless

macro yo-html

JSX-like macro similar to what you can find in React or Yew but without framework nor trait

1 unstable release

0.1.0 Mar 13, 2024

#2051 in Web programming

23 downloads per month

MIT/Apache

28KB
423 lines

yo-html

JSX-like macro similar to what you can find in React or Yew but without framework nor trait.

let name = "Tippsie";
let class = "class";
let onclick = todo!();
let dynamic_attribute = "style";
html! {
    <>      // Support fragments
        <div class="important">{"Hello "}<strong>{name}</strong></div>
        <ul class=["list", "of", class]>
            <li><button {onclick}>{"Click here"}</button></li>
            <li {dynamic_attribute}="color:red"></li>
            <li>("%x", 42)</li>     // Shorthand for: format_args!("%x", 42)
        </ul>
    </>
}

An example of web framework is provided in the examples directory but you need to make your own for this macro to be usable.


lib.rs:

JSX-like macro similar to what you can find in React or Yew but without framework nor trait.

let name = "Tippsie";
let class = "class";
let onclick = todo!();
let dynamic_attribute = "style";
html! {
    <>      // Support fragments
        <div class="important">{"Hello "}<strong>{name}</strong></div>
        <ul class=["list", "of", class]>
            <li><button {onclick}>{"Click here"}</button></li>
            <li {dynamic_attribute}="color:red"></li>
            <li>("%x", 42)</li>     // Shorthand for: format_args!("%x", 42)
        </ul>
    </>
}

An example of web framework is provided in the examples directory but you need to make your own for this macro to be usable.

Dependencies

~325–780KB
~19K SLoC