aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorLibravatar René Kijewski <kijewski@library.vetmed.fu-berlin.de>2021-07-01 20:46:19 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2021-07-05 10:34:20 +0200
commit20a5f7af7b1195bc8ffa0612a40a8d95bc30914b (patch)
tree07a5b03796f1a2cc3ba117e65a092432908778fc /testing
parent4d92ed520caf1595bd15469e06e882d6379993db (diff)
downloadaskama-20a5f7af7b1195bc8ffa0612a40a8d95bc30914b.tar.gz
askama-20a5f7af7b1195bc8ffa0612a40a8d95bc30914b.tar.bz2
askama-20a5f7af7b1195bc8ffa0612a40a8d95bc30914b.zip
Add loop variable shadowing test
Diffstat (limited to 'testing')
-rw-r--r--testing/tests/loops.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/testing/tests/loops.rs b/testing/tests/loops.rs
index 3bba428..7b008a2 100644
--- a/testing/tests/loops.rs
+++ b/testing/tests/loops.rs
@@ -214,3 +214,24 @@ fn test_for_vec_attr_range() {
};
assert_eq!(t.render().unwrap(), "1 2 3 4 5 6 ");
}
+
+#[derive(Template)]
+#[template(
+ source = "{% for v in v %}{% let v = v %}{% for v in v.iterable %}{% let v = v %}{{ v }} {% endfor %}{% endfor %}",
+ ext = "txt"
+)]
+struct ForVecAttrSliceShadowingTemplate {
+ v: Vec<ForVecAttrSlice>,
+}
+
+#[test]
+fn test_for_vec_attr_slice_shadowing() {
+ let t = ForVecAttrSliceShadowingTemplate {
+ v: vec![
+ ForVecAttrSlice { iterable: &[1, 2] },
+ ForVecAttrSlice { iterable: &[3, 4] },
+ ForVecAttrSlice { iterable: &[5, 6] },
+ ],
+ };
+ assert_eq!(t.render().unwrap(), "1 2 3 4 5 6 ");
+}