From 504a5f41b3e33a45ed14598d2603277ad5b1a355 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sat, 4 Feb 2017 10:59:35 +0100 Subject: Add basic support for loops --- testing/templates/for.html | 3 +++ testing/tests/simple.rs | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 testing/templates/for.html (limited to 'testing') 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, +} + +#[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"); +} -- cgit