diff --git a/CHANGELOG.md b/CHANGELOG.md index 7620c26..915f1aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased] +- [Added] Allow terminating void elements with semicolons (`;`) + [#96](https://github.com/lfairy/maud/pull/96) - [Changed] Update to Rocket 0.3 [#94](https://github.com/lfairy/maud/pull/94) - [Changed] Port to new proc macro interface diff --git a/maud/tests/basic_syntax.rs b/maud/tests/basic_syntax.rs index dd40a83..009177f 100644 --- a/maud/tests/basic_syntax.rs +++ b/maud/tests/basic_syntax.rs @@ -54,14 +54,20 @@ fn nesting_elements() { #[test] fn empty_elements() { - let s = html!("pinkie" br/ "pie").into_string(); + let s = html!("pinkie" br; "pie").into_string(); + assert_eq!(s, "pinkie<br>pie"); +} + +#[test] +fn empty_elements_slash() { + let s = html!("pinkie" br / "pie").into_string(); assert_eq!(s, "pinkie<br>pie"); } #[test] fn simple_attributes() { let s = html! { - link rel="stylesheet" href="styles.css"/ + link rel="stylesheet" href="styles.css"; section id="midriff" { p class="hotpink" "Hello!" } @@ -73,7 +79,7 @@ fn simple_attributes() { #[test] fn empty_attributes() { - let s = html!(div readonly? input type="checkbox" checked? /).into_string(); + let s = html!(div readonly? input type="checkbox" checked?;).into_string(); assert_eq!(s, r#"<div readonly><input type="checkbox" checked></div>"#); } @@ -81,10 +87,10 @@ fn empty_attributes() { fn toggle_empty_attributes() { let rocks = true; let s = html!({ - input checked?[true] / - input checked?[false] / - input checked?[rocks] / - input checked?[!rocks] / + input checked?[true]; + input checked?[false]; + input checked?[rocks]; + input checked?[!rocks]; }).into_string(); assert_eq!(s, concat!( r#"<input checked>"#, diff --git a/maud_macros/src/parse.rs b/maud_macros/src/parse.rs index 0357b04..950aa4c 100644 --- a/maud_macros/src/parse.rs +++ b/maud_macros/src/parse.rs @@ -378,6 +378,7 @@ impl Parser { self.attrs(render)?; render.element_open_end(); match self.peek() { + Some(TokenTree { kind: TokenNode::Op(';', _), .. }) | Some(TokenTree { kind: TokenNode::Op('/', _), .. }) => { // Void element self.advance();