# html-string Simple, server-side html generation in Rust. Warning: WIP ## Examples Use functions named after html tags: ```rust use html_string::tags::*; let html = html([head(()), body(div(()))]); assert_eq!( format!("{html}"), "
" ) ``` Tag functions are very flexible in the type of arguments you can provide: ```rust use html_string::tags::*; use html_string::attr; // Empty node div(()); // Another html node div(div(())); // A list of nodes div([p(()), p(())]); // Just text div("foot"); // `Strings` also work div(String::from("hello")); // Attributes div(attr! { "class" => "box", "id" => "box-1" }); // Attributes and text (notice the tuple) div((attr! { "class" => "box" }, "foo")); // Attributes and a node div((attr! { "class" => "box" }, div(()))); // Attributes and a list of nodes div((attr! { "class" => "box" }, [p(()), p(())])); ``` Why use a template language when you are already using rust: ``` use html_string::tags::*; use html_string::Node; let items = vec!["apples", "oranges", "books"]; let list = ul(items.into_iter().map(|i| li(i)).collect::>()); assert_eq!( format!("{list}"), "" ); ```