* Properly group splice expressions

* Add test for fix
This commit is contained in:
Matt Fellenz 2023-06-11 02:58:43 -07:00 committed by GitHub
parent b7e5768d44
commit 79259ab426
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions
maud/tests
maud_macros/src

View file

@ -124,3 +124,9 @@ fn nested_macro_invocation() {
let result = html! { (format!("{best_pony} is best pony")) };
assert_eq!(result.into_string(), "Pinkie Pie is best pony");
}
#[test]
fn expression_grouping() {
let result = html! { (1 + 1) };
assert_eq!(result.into_string(), "2");
}

View file

@ -103,7 +103,7 @@ impl Generator {
fn splice(&self, expr: TokenStream, build: &mut Builder) {
let output_ident = self.output_ident.clone();
build.push_tokens(quote!(maud::macro_private::render_to!(&#expr, &mut #output_ident);));
build.push_tokens(quote!(maud::macro_private::render_to!(&(#expr), &mut #output_ident);));
}
fn element(&self, name: TokenStream, attrs: Vec<Attr>, body: ElementBody, build: &mut Builder) {