From 468f376bfc2cf3e09addac37cd144de56b5f93bf Mon Sep 17 00:00:00 2001
From: Anthony Nowell <anowell@gmail.com>
Date: Wed, 27 Sep 2017 01:53:35 -0600
Subject: implement basic match functionality

---
 testing/templates/match.html |  6 ++++++
 testing/tests/matches.rs     | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 testing/templates/match.html
 create mode 100644 testing/tests/matches.rs

(limited to 'testing')

diff --git a/testing/templates/match.html b/testing/templates/match.html
new file mode 100644
index 0000000..51950b4
--- /dev/null
+++ b/testing/templates/match.html
@@ -0,0 +1,6 @@
+{% match item %}
+{% when Some with (val) %}
+Found {{val}}
+{% when None %}
+Not Found
+{% endmatch %}
diff --git a/testing/tests/matches.rs b/testing/tests/matches.rs
new file mode 100644
index 0000000..4a55615
--- /dev/null
+++ b/testing/tests/matches.rs
@@ -0,0 +1,18 @@
+#[macro_use]
+extern crate askama;
+
+use askama::Template;
+
+#[derive(Template)]
+#[template(path = "match.html")]
+struct MatchTemplate<'a> {
+    item: Option<&'a str>,
+}
+
+#[test]
+fn test_match_option() {
+    let s = MatchTemplate {
+        item: Some("foo"),
+    };
+    assert_eq!(s.render().unwrap(), "\n\nFound foo\n");
+}
-- 
cgit