From e4b8ca3c44b5ede192700d0e4c9ed1c58338c1b6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 6 Dec 2023 17:20:53 +0100 Subject: Allow trailing comma in macro definition and call --- testing/tests/macro.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'testing/tests') diff --git a/testing/tests/macro.rs b/testing/tests/macro.rs index 9b3c63d..3d027d2 100644 --- a/testing/tests/macro.rs +++ b/testing/tests/macro.rs @@ -140,3 +140,33 @@ struct OnlyNamedArgument; fn test_only_named_argument() { assert_eq!(OnlyNamedArgument.render().unwrap(), "hi"); } + +// Check for trailing commas. +#[derive(Template)] +#[template( + source = r#"{% macro button(label , ) %} +{{- label -}} +{% endmacro %} +{%- macro button2(label ,) %} +{% endmacro %} +{%- macro button3(label,) %} +{% endmacro %} +{%- macro button4(label, ) %} +{% endmacro %} +{%- macro button5(label ) %} +{% endmacro %} + +{%- call button(label="hi" , ) -%} +{%- call button(label="hi" ,) -%} +{%- call button(label="hi",) -%} +{%- call button(label="hi", ) -%} +{%- call button(label="hi" ) -%} +"#, + ext = "html" +)] +struct TrailingComma; + +#[test] +fn test_trailing_comma() { + assert_eq!(TrailingComma.render().unwrap(), "hihihihihi"); +} -- cgit