aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/templates/match.html6
-rw-r--r--testing/tests/matches.rs18
2 files changed, 24 insertions, 0 deletions
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");
+}