Skip to content

vidhanio/hypertext

Repository files navigation

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, such as those used by htmx and Alpine.js
  • #![no_std] support
  • Automatic escaping
  • Extremely fast, using lazy rendering by default to avoid unnecessary allocations
  • Support for two well-known HTML macro syntaxes, maud and rsx
  • #![forbid(unsafe_code)] across the entire codebase
  • Integration with all major web frameworks, enabled by their respective feature flags

Projects Using hypertext

Make a pull request to list your project here!

Example

use hypertext::prelude::*;

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

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

// or, alternatively:

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

About

A blazing fast type-checked HTML macro crate.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages