html!() { /* proc-macro */ }Expand description
A macro for writing HTML inline in Rust. It compiles down to highly optimized string concatenations at compile time, and automatically escapes dynamic variables to prevent XSS.
Dynamic URL attributes (href, src, action, …) render # for script or
non-media data: URLs; dynamic style/on* values are trusted-only.
§Example
This block is ignored only in the standalone proc-macro crate because the
expansion deliberately calls the rullst::html runtime and adding that
facade here would create a circular development dependency. The same dynamic
expansion is compiled and asserted in rullst/tests/html_snapshot_tests.rs.
ⓘ
use rullst_macros::html;
let name = "Mundo";
let page = html! {
<div class="container">
<h1>"Olá, " {name} "!"</h1>
</div>
};
assert!(page.contains("Olá, Mundo!"));