# Ritz Ritz is a simple templating library that has [JSX][jsx-intro]-like syntax powered by [Snax](https://github.com/LPGhatguy/snax). ## Requirements Ritz requires Rust 1.32 or newer. Some things are still a bit in flux, so I'm sorry in advance if I break anything! ## Examples ### Simple Page ```rust use ritz::html; fn main() { let page_title = "Hello, world, from Snax!"; let page = html! { /* Ritz supports regular multi-line Rust comments. */ /* Literal strings need to be quoted, unlike JSX. This makes whitespace much more explicit, which is useful! */ "Hello, Snax!" /* Ritz supports embedding Rust expressions that return `impl IntoIterator`. String and &str work great here! */

{ page_title }

}; // The result of the html! macro is ritz::HtmlContent. // It implements Display and gives you compact HTML without a doctype! println!(""); println!("{}", page); } ``` ### Composition via functions Ritz is designed to work well when using functions to reuse pieces of HTML! ```rust use ritz::{html, Fragment, HtmlContent}; fn user_widget<'a>(name: &'a str, age: u32) -> HtmlContent<'a> { html! {
{ name } " is " { age.to_string() } " years old!"
} } fn users() -> HtmlContent<'static> { let users = vec![ ("Gandalf", 34), ("Arwen Undómie", 75), ("Primula Brandybuck", 133), ]; html! {
{ Fragment::new(users.iter().map(|(name, age)| user_widget(name, *age))) }
} } ``` ## License Ritz is available under the MIT license. See [LICENSE.txt](LICENSE.txt) for details. [jsx-intro]: https://reactjs.org/docs/introducing-jsx.html