diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2019-02-20 20:02:26 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2019-02-20 20:41:17 +0100 |
commit | 292bf7baed7e96ab44085643f960014910835e53 (patch) | |
tree | c94ec46ad2b5537616ea7134715fd86dd0356314 /testing/tests | |
parent | c851edb29bb0242f4e0f6afb00f37ec59d15d7ef (diff) | |
download | askama-292bf7baed7e96ab44085643f960014910835e53.tar.gz askama-292bf7baed7e96ab44085643f960014910835e53.tar.bz2 askama-292bf7baed7e96ab44085643f960014910835e53.zip |
Allow referencing self as a variable (fixes #207)
Diffstat (limited to '')
-rw-r--r-- | testing/tests/vars.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/testing/tests/vars.rs b/testing/tests/vars.rs index 04f9ff2..da8aef6 100644 --- a/testing/tests/vars.rs +++ b/testing/tests/vars.rs @@ -43,3 +43,17 @@ fn test_let_decl() { }; assert_eq!(t.render().unwrap(), "bar"); } + +#[derive(Template)] +#[template( + source = "{% for v in self.0 %}{{ v }}{% endfor %}", + ext = "txt", + print = "code" +)] +struct SelfIterTemplate(Vec<usize>); + +#[test] +fn test_self_iter() { + let t = SelfIterTemplate(vec![1, 2, 3]); + assert_eq!(t.render().unwrap(), "123"); +} |