hypertext

Crates.iohypertext
lib.rshypertext
version0.5.1
sourcesrc
created_at2024-01-12 03:35:03.277917
updated_at2024-06-18 11:48:05.308186
descriptionA blazing fast type-checked HTML macro crate.
homepagehttps://github.com/vidhanio/hypertext
repositoryhttps://github.com/vidhanio/hypertext
max_upload_size
id1097274
size59,269
Vidhan Bhatt (vidhanio)

documentation

https://docs.rs/hypertext

README

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();
Commit count: 45

cargo fmt