From 2000af89016f6145bf42b72afaafe68c0a8da4a4 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 6 Jan 2017 11:23:21 +0100 Subject: Add basic test case for filters --- testing/templates/filters.html | 1 + testing/tests/filters.rs | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 testing/templates/filters.html create mode 100644 testing/tests/filters.rs 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 is unsafe & should be escaped".to_string(), + }; + assert_eq!(s.render(), + "my <html> is unsafe & should be escaped\n"); +} -- cgit