From 985cbd34dff6ddd60b37f1c89bb7c3de2d2bc669 Mon Sep 17 00:00:00 2001 From: Matt Fellenz Date: Tue, 6 Jun 2023 15:50:19 -0700 Subject: [PATCH 1/2] Properly group splice expressions --- maud_macros/src/generate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maud_macros/src/generate.rs b/maud_macros/src/generate.rs index c9ba9fb6..ee27a55d 100644 --- a/maud_macros/src/generate.rs +++ b/maud_macros/src/generate.rs @@ -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, body: ElementBody, build: &mut Builder) { From ccf4c66d00c972973bfb601f9c39f1a8a81c8cfe Mon Sep 17 00:00:00 2001 From: Matt Fellenz Date: Sat, 10 Jun 2023 23:35:41 -0700 Subject: [PATCH 2/2] Add test for fix --- maud/tests/splices.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maud/tests/splices.rs b/maud/tests/splices.rs index d3fd511f..8665e84b 100644 --- a/maud/tests/splices.rs +++ b/maud/tests/splices.rs @@ -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"); +}