aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-01-06 11:23:21 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-01-06 13:24:44 +0100
commit2000af89016f6145bf42b72afaafe68c0a8da4a4 (patch)
tree5dad1cd891ac4b3e5e42affb227c2d22856f4519
parent825ad5f816657bb6602467784491f3430320b4a5 (diff)
downloadaskama-2000af89016f6145bf42b72afaafe68c0a8da4a4.tar.gz
askama-2000af89016f6145bf42b72afaafe68c0a8da4a4.tar.bz2
askama-2000af89016f6145bf42b72afaafe68c0a8da4a4.zip
Add basic test case for filters
Diffstat (limited to '')
-rw-r--r--testing/templates/filters.html1
-rw-r--r--testing/tests/filters.rs22
2 files changed, 23 insertions, 0 deletions
diff --git a/testing/templates/filters.html b/testing/templates/filters.html
new file mode 100644
index 0000000..77f5048
--- /dev/null
+++ b/testing/templates/filters.html
@@ -0,0 +1 @@
+{{ strvar|e }}
diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs
new file mode 100644
index 0000000..abde750
--- /dev/null
+++ b/testing/tests/filters.rs
@@ -0,0 +1,22 @@
+#![feature(proc_macro)]
+
+#[macro_use]
+extern crate askama_derive;
+extern crate askama;
+
+use askama::Template;
+
+#[derive(Template)]
+#[template(path = "filters.html")]
+struct TestTemplate {
+ strvar: String,
+}
+
+#[test]
+fn filter_escape() {
+ let s = TestTemplate {
+ strvar: "my <html> is unsafe & should be escaped".to_string(),
+ };
+ assert_eq!(s.render(),
+ "my &lt;html&gt; is unsafe &amp; should be escaped\n");
+}