diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-02-04 10:59:35 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-02-04 10:59:35 +0100 |
commit | 504a5f41b3e33a45ed14598d2603277ad5b1a355 (patch) | |
tree | 3c5a113d6751328ae809ca00a71f482c2ecbe157 /testing | |
parent | 4eb124b7730630bf05dfe1f34f69af4f4f5b67a3 (diff) | |
download | askama-504a5f41b3e33a45ed14598d2603277ad5b1a355.tar.gz askama-504a5f41b3e33a45ed14598d2603277ad5b1a355.tar.bz2 askama-504a5f41b3e33a45ed14598d2603277ad5b1a355.zip |
Add basic support for loops
Diffstat (limited to '')
-rw-r--r-- | testing/templates/for.html | 3 | ||||
-rw-r--r-- | testing/tests/simple.rs | 15 |
2 files changed, 18 insertions, 0 deletions
diff --git a/testing/templates/for.html b/testing/templates/for.html new file mode 100644 index 0000000..c38e6bb --- /dev/null +++ b/testing/templates/for.html @@ -0,0 +1,3 @@ +{% for s in strings %} + {{ s }} +{% endfor %} diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index b8274c3..ab5e209 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -64,3 +64,18 @@ fn test_else_if() { let s = ElseIfTemplate { cond: false, check: true }; assert_eq!(s.render(), "checked\n"); } + + +#[derive(Template)] +#[template(path = "for.html")] +struct ForTemplate { + strings: Vec<String>, +} + +#[test] +fn test_for() { + let s = ForTemplate { + strings: vec!["A".to_string(), "alfa".to_string(), "1".to_string()], + }; + assert_eq!(s.render(), "\n A\n\n alfa\n\n 1\n\n"); +} |