14 releases

0.6.2 Jan 1, 2025
0.5.2 Nov 18, 2024
0.5.1 Jun 18, 2024
0.5.0 Jan 20, 2024

#72 in Template engine

Download history 138/week @ 2024-12-04 142/week @ 2024-12-11 109/week @ 2024-12-18 28/week @ 2024-12-25 537/week @ 2025-01-01 164/week @ 2025-01-08 178/week @ 2025-01-15 207/week @ 2025-01-22 154/week @ 2025-01-29 191/week @ 2025-02-05 188/week @ 2025-02-12 318/week @ 2025-02-19 403/week @ 2025-02-26 418/week @ 2025-03-05 334/week @ 2025-03-12 310/week @ 2025-03-19

1,524 downloads per month

MIT license

64KB
953 lines

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>
            { shopping_list.iter().zip(1..).map(|(&item, i)| hypertext::rsx_move! {
                <li class="item">
                    <input id=format!("item-{i}") type="checkbox">
                    <label for=format!("item-{i}")>{ item }</label>
                </li>
            }).render_all() }
        </ul>
    </div>
}
.render();

Dependencies

~0.6–13MB
~165K SLoC