aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorLibravatar Guillaume Gomez <guillaume1.gomez@gmail.com>2023-12-06 17:20:53 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-12-07 11:03:26 +0100
commite4b8ca3c44b5ede192700d0e4c9ed1c58338c1b6 (patch)
treeb61c656c5ba74bae82ccfdc51f22a01f35c28120 /testing
parent7f30a657f6530b4422eedb26977ab5b831a48bd8 (diff)
downloadaskama-e4b8ca3c44b5ede192700d0e4c9ed1c58338c1b6.tar.gz
askama-e4b8ca3c44b5ede192700d0e4c9ed1c58338c1b6.tar.bz2
askama-e4b8ca3c44b5ede192700d0e4c9ed1c58338c1b6.zip
Allow trailing comma in macro definition and call
Diffstat (limited to 'testing')
-rw-r--r--testing/tests/macro.rs30
1 files changed, 30 insertions, 0 deletions
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");
+}