aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests/vars.rs
diff options
context:
space:
mode:
authorLibravatar René Kijewski <kijewski@library.vetmed.fu-berlin.de>2021-07-17 13:40:49 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2021-07-30 11:45:56 +0200
commit268d8250fb0a9cdcbbd760bdf39424ed02fd1920 (patch)
tree02a31fa920a29cff2420e597158637619cf7606c /testing/tests/vars.rs
parent1622df7aeecb71fca2da630330513b26cefef16b (diff)
downloadaskama-268d8250fb0a9cdcbbd760bdf39424ed02fd1920.tar.gz
askama-268d8250fb0a9cdcbbd760bdf39424ed02fd1920.tar.bz2
askama-268d8250fb0a9cdcbbd760bdf39424ed02fd1920.zip
Use "target()" to parse "when" block
`target()` as used in parsing "let" and "if let" implements parsing nested tuples and structs. But it does not implement parsing literals. The functions `match_variant()` and `with_parameters()` as used in parsing "when" blocks do not implement parsing nested structs, but it implements parsing literals. This PR combines `match_variant()` and `with_parameters()` into `target()`, so that all `{%when%}` support nested structs, too.
Diffstat (limited to 'testing/tests/vars.rs')
-rw-r--r--testing/tests/vars.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/testing/tests/vars.rs b/testing/tests/vars.rs
index 75d10e5..5447351 100644
--- a/testing/tests/vars.rs
+++ b/testing/tests/vars.rs
@@ -105,3 +105,29 @@ fn test_destruct_tuple() {
};
assert_eq!(t.render().unwrap(), "wxyz\nwz\nw");
}
+
+#[derive(Template)]
+#[template(
+ source = "{% let x = 1 %}{% for x in x..=x %}{{ x }}{% endfor %}",
+ ext = "txt"
+)]
+struct DeclRange;
+
+#[test]
+fn test_decl_range() {
+ let t = DeclRange;
+ assert_eq!(t.render().unwrap(), "1");
+}
+
+#[derive(Template)]
+#[template(
+ source = "{% let x %}{% let x = 1 %}{% for x in x..=x %}{{ x }}{% endfor %}",
+ ext = "txt"
+)]
+struct DeclAssignRange;
+
+#[test]
+fn test_decl_assign_range() {
+ let t = DeclAssignRange;
+ assert_eq!(t.render().unwrap(), "1");
+}