use htmxpress::{Element, HtmxElement}; #[derive(Element)] struct Test { #[element("p")] foo: Option, #[element("p")] #[format("bar: {}")] bar: Option, #[element("p")] #[default("foo")] qux: Option, #[element("p")] #[default("qua")] #[format("{}ck")] qua: Option, } #[derive(Element)] struct TestTwo { #[nest] _foo: Option, } #[derive(Element)] struct Child { #[element("p")] #[format("c: {}")] #[default("foo")] c: Option, } #[test] fn works() { let test = Test { foo: None, bar: Some(420), qux: None, qua: None, }; let html = r#"

bar: 420

foo

quack

"#; assert_eq!(html, test.to_htmx()) } #[test] fn works_nested() { let test = TestTwo { _foo: Some(Child { c: Some("s".to_string()), }), }; let html = r#"

c: s

"#; assert_eq!(html, test.to_htmx()) }