# htmlm (for a lack of free names)
This crate implements simple html template macros without any dependencies. Use at your own risk.
# Example
```rust
let escape = htmlm::html! {
{""}
};
assert_eq!(escape, "<script>alert('css')</script>");
let no_escape = htmlm::html! {
!{""}
};
assert_eq!(no_escape, "");
let if_expr = htmlm::html! {
if let Some(y) = Some("yeh") {
y
} else {
"nah"
}
};
assert_eq!(if_expr, "yeh
");
let match_expr = htmlm::html! {
match true {
false => { "nah" }
trye => { "yeh" }
}
};
assert_eq!(match_expr, "yeh
");
let for_expr = htmlm::html! {
for n in ["a", "b", "c"] {
!n
} else {
"no content"
}
};
assert_eq!(for_expr, "");
fn component(buf: &mut String, hello: &str) {
htmlm::write_html! { (buf)
hello
}
}
use std::fmt::Write;
let mut buf = String::new();
htmlm::write_html! { (buf)
|f|{component(f, "hello")}" there"
}
assert_eq!(buf, "hello there
");
```