From bef88f1696b828caf72695561c2270456f35894d Mon Sep 17 00:00:00 2001
From: yossyJ <28825627+yossyJ@users.noreply.github.com>
Date: Fri, 4 Jan 2019 23:12:44 +0900
Subject: Add support for tuple

---
 testing/templates/for.html |  3 +++
 testing/templates/let.html |  1 +
 testing/tests/loops.rs     |  7 ++++++-
 testing/tests/vars.rs      | 16 ++++++++++++++++
 4 files changed, 26 insertions(+), 1 deletion(-)

(limited to 'testing')

diff --git a/testing/templates/for.html b/testing/templates/for.html
index 8b4032d..f749752 100644
--- a/testing/templates/for.html
+++ b/testing/templates/for.html
@@ -1,3 +1,6 @@
 {% for s in strings %}
   {{- loop.index0 }}. {{ s }}{% if loop.first %} (first){% endif %}
 {% endfor %}
+{% for (s1, s2) in tuple_strings %}
+  {{- loop.index0 }}. {{ s1 }},{{ s2 }}{% if loop.first %} (first){% endif %}
+{% endfor %}
diff --git a/testing/templates/let.html b/testing/templates/let.html
index 5b19255..034e8d4 100644
--- a/testing/templates/let.html
+++ b/testing/templates/let.html
@@ -1 +1,2 @@
 {% let v = s %}{{ v }}
+{% let (v1,v2) = t %}{{ v1 }}{{ v2 }}
\ No newline at end of file
diff --git a/testing/tests/loops.rs b/testing/tests/loops.rs
index 3dfad38..b5fac7c 100644
--- a/testing/tests/loops.rs
+++ b/testing/tests/loops.rs
@@ -4,14 +4,19 @@ use askama::Template;
 #[template(path = "for.html")]
 struct ForTemplate<'a> {
     strings: Vec<&'a str>,
+    tuple_strings: Vec<(&'a str, &'a str)>,
 }
 
 #[test]
 fn test_for() {
     let s = ForTemplate {
         strings: vec!["A", "alfa", "1"],
+        tuple_strings: vec![("B", "beta")],
     };
-    assert_eq!(s.render().unwrap(), "0. A (first)\n1. alfa\n2. 1\n");
+    assert_eq!(
+        s.render().unwrap(),
+        "0. A (first)\n1. alfa\n2. 1\n\n0. B,beta (first)\n"
+    );
 }
 
 #[derive(Template)]
diff --git a/testing/tests/vars.rs b/testing/tests/vars.rs
index 87af3f6..04f9ff2 100644
--- a/testing/tests/vars.rs
+++ b/testing/tests/vars.rs
@@ -12,6 +12,22 @@ fn test_let() {
     assert_eq!(t.render().unwrap(), "foo");
 }
 
+#[derive(Template)]
+#[template(path = "let.html")]
+struct LetTupleTemplate<'a> {
+    s: &'a str,
+    t: (&'a str, &'a str),
+}
+
+#[test]
+fn test_let_tuple() {
+    let t = LetTupleTemplate {
+        s: "foo",
+        t: ("bar", "bazz"),
+    };
+    assert_eq!(t.render().unwrap(), "foo\nbarbazz");
+}
+
 #[derive(Template)]
 #[template(path = "let-decl.html")]
 struct LetDeclTemplate<'a> {
-- 
cgit