Skip to content

DougLau/hatmil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hatmil is a user-friendly 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>"
);

About

Simple HTML builder

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Languages