iet-ui-macros
Compiles the html! macro into straight-line string writes.
iet-ui-macrostoolinghtml! macroHow to use it
html! is a function-like macro that parses literal HTML with rstml and expands to straight-line string writes producing an iet_ui::Markup. Static markup is fused into a single buffer allocation, brace-delimited expressions are escaped inline (strings as attributes, Render types and iterators as children), and text! renders escaped formatted text without a temporary buffer. It is re-exported as iet_ui::html.
// crates/features/iet-ui/src/components.rs
use crate::;
- Element and attribute names must be literal HTML; attribute spreads (
<div {attrs}>) and attribute bindings are compile errors. - Children accept
Option<Markup>, iterators ofRender, and nestedhtml! { ... }; usetext!for formatted, escaped interpolation. .to_string()yields the HTML;.into_string()moves the buffer without copying.
How it works
The proc macro parses the tokens with rstml, then an Emitter accumulates literal HTML into one buffer and expression interpolations into push_str/write_escaped/Render::render_into calls, wrapping the whole expansion in iet_ui::Markup::from_rendered.
flowchart LR H["html! tokens"] --> R["rstml parse2"] R --> EM["Emitter"] EM --> LT["fused literal buffer"] EM --> WR["writes for expressions"] WR --> WE["write_escaped attributes"] WR --> RI["Render render_into children"] LT --> OUT["iet_ui Markup from_rendered"] WE --> OUT RI --> OUT
What it implements
- Concrete mechanism; see the public API below.
What's inside
Modules
src/lib.rssrc/render.rssrc/script.rs
Public API
(root)
pub fn script(input: proc_macro::TokenStream) -> proc_macro::TokenStreampub fn static_view(input: proc_macro::TokenStream) -> proc_macro::TokenStreampub fn html(input: proc_macro::TokenStream) -> proc_macro::TokenStream
render
pub fn expand(input: TokenStream) -> syn::Result<TokenStream>pub fn expand_static(input: TokenStream) -> syn::Result<TokenStream>
script
pub fn expand(input: TokenStream) -> syn::Result<TokenStream>
Depends on
- No other framework crate: it stands alone.
External crates: oxc_allocator, oxc_parser, oxc_span, proc-macro2, quote, rstml, sha2, syn
Cargo features
scripts— dep:oxc_allocator, dep:oxc_parser, dep:oxc_span, dep:sha2
Used by
In this repository
- Not used by a checked-in example yet.
Source: crates/macros/iet-ui-macros