aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests/matches.rs
diff options
context:
space:
mode:
authorLibravatar René Kijewski <kijewski@library.vetmed.fu-berlin.de>2022-01-31 09:02:17 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2022-01-31 11:30:35 +0100
commit91874702f0f3581549c129369a8bc0783006b5fa (patch)
tree5b70acb63e7634cc8b9d1dfc29eabd7b4d30238a /testing/tests/matches.rs
parentda0b6ead0e75082bfffa24f8529d1f83961ba45c (diff)
downloadaskama-91874702f0f3581549c129369a8bc0783006b5fa.tar.gz
askama-91874702f0f3581549c129369a8bc0783006b5fa.tar.bz2
askama-91874702f0f3581549c129369a8bc0783006b5fa.zip
Allow comments in `{% match %}` and remove panic!
Diffstat (limited to '')
-rw-r--r--testing/tests/matches.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/testing/tests/matches.rs b/testing/tests/matches.rs
index 206cd1d..35c1204 100644
--- a/testing/tests/matches.rs
+++ b/testing/tests/matches.rs
@@ -172,3 +172,28 @@ fn test_match_option_result_option() {
};
assert_eq!(s.render().unwrap(), "num=4711");
}
+
+#[derive(Template)]
+#[template(
+ ext = "txt",
+ source = r#"
+{%- match good -%}
+ {#- when good, then good -#}
+ {%- when true -%}
+ good
+ {%- when _ -%}
+ bad
+{%- endmatch -%}"#
+)]
+struct MatchWithComment {
+ good: bool,
+}
+
+#[test]
+fn test_match_with_comment() {
+ let s = MatchWithComment { good: true };
+ assert_eq!(s.render().unwrap(), "good");
+
+ let s = MatchWithComment { good: false };
+ assert_eq!(s.render().unwrap(), "bad");
+}