Skip to content

Incorporating Rust logic within HTML templates, PHP style.

Notifications You must be signed in to change notification settings

lorlouis/html_template

Repository files navigation

html_template

Incorporating Rust logic within HTML templates, PHP style.

Basic usage

Referencing a variable within a template

let title = "hello world";
let dom: String = html!{
    <html>
        <title>{title.to_string()}</title>
        "wowo mwmw"
    </html>
}.to_string();
// "<html><title>hello world</title>wowo mwmw</html>"

Repeating HTML for each element

let dom: Root = html!{
    { (0..3).map(|v| html!({[move] format!("{}, ", v)})).collect() }
}.into();
// "0, 1, 2, "

NOTE: [move] is needed in the second closure to take ownership of v

About

Incorporating Rust logic within HTML templates, PHP style.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages