11 releases

0.5.2 Nov 18, 2024
0.5.1 Jun 18, 2024
0.5.0 Jan 20, 2024
0.4.1 Jan 18, 2024
0.1.0 Jan 12, 2024

#14 in #hypertext

Download history 82/week @ 2024-08-19 65/week @ 2024-08-26 77/week @ 2024-09-02 82/week @ 2024-09-09 28/week @ 2024-09-16 82/week @ 2024-09-23 57/week @ 2024-09-30 37/week @ 2024-10-07 37/week @ 2024-10-14 97/week @ 2024-10-21 77/week @ 2024-10-28 91/week @ 2024-11-04 31/week @ 2024-11-11 244/week @ 2024-11-18 178/week @ 2024-11-25 141/week @ 2024-12-02

597 downloads per month
Used in hypertext

MIT license

66KB
2K 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>
            { 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–1.1MB
~25K SLoC