20 unstable releases (7 breaking)

Uses new Rust 2024

0.8.0 May 3, 2025
0.6.5 May 1, 2025
0.6.2 Jan 1, 2025
0.5.2 Nov 18, 2024
0.5.0 Jan 20, 2024

#56 in Template engine

Download history 478/week @ 2025-03-03 373/week @ 2025-03-10 285/week @ 2025-03-17 278/week @ 2025-03-24 157/week @ 2025-03-31 272/week @ 2025-04-07 413/week @ 2025-04-14 540/week @ 2025-04-21 903/week @ 2025-04-28 403/week @ 2025-05-05 573/week @ 2025-05-12 216/week @ 2025-05-19 228/week @ 2025-05-26 235/week @ 2025-06-02 507/week @ 2025-06-09 422/week @ 2025-06-16

1,405 downloads per month

MIT license

76KB
1K SLoC

hypertext

A blazing fast type-checked HTML macro crate.

Features

  • Type checking for element names/attributes
    • Completely extensible for use with non-standard elements/attributes
  • #![no_std] support
  • Automatic escaping
  • Lazy rendering by default to avoid multiple allocations
    • Results in outstanding performance in cases of nested documents, which other libraries may falter in

Projects Using hypertext

Make a pull request to list your project here!

Example

use hypertext::{html_elements, GlobalAttributes, RenderIterator, Renderable};

let shopping_list = ["milk", "eggs", "bread"];

let shopping_list_maud = hypertext::maud! {
    div {
        h1 { "Shopping List" }
        ul {
            @for (&item, i) in shopping_list.iter().zip(1..) {
                li.item {
                    input #{ "item-" (i) } type="checkbox";
                    label for={ "item-" (i) } { (item) }
                }
            }
        }
    }
}
.render();

// or, alternatively:

let shopping_list_rsx = hypertext::rsx! {
    <div>
        <h1>Shopping List</h1>
        <ul>
            @for (&item, i) in shopping_list.iter().zip(1..) {
                <li class="item">
                    <input id={ format!("item-{i}") } type="checkbox" />
                    <label for={ format!("item-{i}") }>{ item }</label>
                </li>
            }
        </ul>
    </div>
}
.render();

Dependencies

~0.6–12MB
~163K SLoC