Skip to content

Commit

Permalink
Fix #382 (#383)
Browse files Browse the repository at this point in the history
* Properly group splice expressions

* Add test for fix
  • Loading branch information
mattfbacon authored Jun 11, 2023
1 parent b7e5768 commit 79259ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions maud/tests/splices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
2 changes: 1 addition & 1 deletion maud_macros/src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 79259ab

Please sign in to comment.