hatmil

Crates.iohatmil
lib.rshatmil
version0.7.2
created_at2025-04-04 15:31:35.870722+00
updated_at2025-08-20 16:37:27.67397+00
descriptionSimple HTML builder
homepage
repositoryhttps://github.com/DougLau/hatmil
max_upload_size
id1620223
size45,348
Douglas Lau (DougLau)

documentation

https://docs.rs/hatmil

README

Simple HTML builder

With an Html builder, elements can be created using methods with a matching name, such as a, body, div, or table. These methods return an Elem, which borrows from the Html, and can be closed with the end method. VoidElem elements, like img and input, do not need to be closed.

Text content can be added using the text or text_len methods, which will automatically escape characters as needed. For content which has already been escaped, use the raw method.

After creating all elements, use Display (format, to_string(), etc) to get the HTML. All open tags will be closed automatically.

use hatmil::Html;

let mut html = Html::new();
html.div().id("a_div").text("Hello").end();
html.button().class("rounded").text("Press Me!");
assert_eq!(
    html.to_string(),
    "<div id=\"a_div\">Hello</div><button class=\"rounded\">Press Me!</button>"
);
Commit count: 60

cargo fmt