4 releases (2 breaking)

Uses new Rust 2024

0.3.0 Jun 30, 2025
0.2.1 Jun 4, 2025
0.2.0 Jun 4, 2025
0.1.0 Nov 2, 2024

#281 in Template engine

Download history 241/week @ 2025-06-03 3/week @ 2025-06-10 1/week @ 2025-06-17 64/week @ 2025-06-24 58/week @ 2025-07-01 5/week @ 2025-07-08

215 downloads per month

MIT license

20KB
289 lines

gen-html

gen-html is a templating library for generating HTML from Rust.

Features

  • Fasthtml! macro generates code that is as fast as writing to a string by hand.
  • Conditional rendering — you can use if, for and match inside your templates.
  • Automatic escaping, however you can opt-out using Raw<T>.
  • Type safety — HTML tags and attributes are checked at compile time.
  • Integration with the rust web ecosystem (axum, actix-web).

Example

use gen_html::html;

let series = ["Breaking Bad", "Better Call Saul", "Dexter"];

let markup = html! {
    ol {
        for title in series {
            li { (title) }
        }
    }
};

println!("{}", markup);

Contributing

See CONTRIBUTING.md

License

This project is licensed under MIT license.

Dependencies

~0.2–12MB
~128K SLoC