diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-03-07 21:00:44 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-03-07 21:00:44 +0100 |
commit | 0eeb5d1b2d998f3ea56b5682f618a57443cd8aef (patch) | |
tree | 2764ff47873085265047cc155e71af5f465f37d9 /testing/tests/loops.rs | |
parent | a0a3e4018c9fe1d23e0b53651804939a2711edde (diff) | |
download | askama-0eeb5d1b2d998f3ea56b5682f618a57443cd8aef.tar.gz askama-0eeb5d1b2d998f3ea56b5682f618a57443cd8aef.tar.bz2 askama-0eeb5d1b2d998f3ea56b5682f618a57443cd8aef.zip |
Add test for nested loops and loops over slices (see #6, #7, #9)
Diffstat (limited to 'testing/tests/loops.rs')
-rw-r--r-- | testing/tests/loops.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/testing/tests/loops.rs b/testing/tests/loops.rs index 4776729..bb245a4 100644 --- a/testing/tests/loops.rs +++ b/testing/tests/loops.rs @@ -16,3 +16,20 @@ fn test_for() { }; assert_eq!(s.render(), "0. A\n1. alfa\n2. 1\n"); } + + +#[derive(Template)] +#[template(path = "nested-for.html", print = "code")] +struct NestedForTemplate<'a> { + seqs: Vec<&'a [&'a str]>, +} + +#[test] +fn test_nested_for() { + let alpha = vec!["a", "b", "c"]; + let numbers = vec!["one", "two"]; + let s = NestedForTemplate { + seqs: vec![&alpha, &numbers], + }; + assert_eq!(s.render(), "1\n 0a1b2c2\n 0one1two"); +} |