9 releases (4 breaking)

0.5.0 Jan 20, 2024
0.4.1 Jan 18, 2024
0.3.2 Jan 12, 2024
0.2.1 Jan 12, 2024
0.1.0 Jan 12, 2024

#162 in Template engine

Download history 78/week @ 2024-01-11 64/week @ 2024-01-18 16/week @ 2024-01-25 7/week @ 2024-02-01 3/week @ 2024-02-15 11/week @ 2024-02-22 30/week @ 2024-02-29 17/week @ 2024-03-07 21/week @ 2024-03-14 1/week @ 2024-03-21 34/week @ 2024-03-28 28/week @ 2024-04-04 17/week @ 2024-04-11 42/week @ 2024-04-18

121 downloads per month

MIT license

62KB
920 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.7–1.5MB
~32K SLoC