| Crates.io | hatmil |
| lib.rs | hatmil |
| version | 0.7.2 |
| created_at | 2025-04-04 15:31:35.870722+00 |
| updated_at | 2025-08-20 16:37:27.67397+00 |
| description | Simple HTML builder |
| homepage | |
| repository | https://github.com/DougLau/hatmil |
| max_upload_size | |
| id | 1620223 |
| size | 45,348 |
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>"
);