use ::classnames::{classname, Class}; use ::render::{component, rsx, Render}; use ::xmltree::{Element, EmitterConfig}; fn main() { let base_class = classname("upgrade-modal"); let html = rsx! { }; let html_str = html.render(); let pretty_html = prettify_html(&html_str); println!("{}", pretty_html); } #[allow(unused_braces)] #[component] pub fn Modal( class: C, title: &'static str, is_important: bool, children: Children, ) -> impl Render { let base_class = classname("modal"); rsx! {

{title}

{children}
} } fn prettify_html<'a>(html: &'a str) -> String { let el = Element::parse(html.as_bytes()).expect("parsexml"); let mut cfg = EmitterConfig::new(); cfg.perform_indent = true; // Sadly this seems to do nothing : ( cfg.write_document_declaration = false; let mut formatted_html_raw = vec![]; el.write_with_config(&mut formatted_html_raw, cfg) .expect("writexml"); String::from_utf8(formatted_html_raw).expect("xml output should be valid utf-8") }