aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--testing/tests/filters.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs
index 665e50d..524014e 100644
--- a/testing/tests/filters.rs
+++ b/testing/tests/filters.rs
@@ -30,3 +30,22 @@ fn filter_format() {
let t = FormatTemplate { var: "formatted" };
assert_eq!(t.render().unwrap(), "\"formatted\"");
}
+
+
+#[derive(Template)]
+#[template(source = "{{ s|myfilter }}")]
+struct MyFilterTemplate<'a> {
+ s: &'a str,
+}
+
+mod filters {
+ pub fn myfilter(s: &str) -> ::askama::Result<String> {
+ Ok(s.replace("oo", "aa").to_string())
+ }
+}
+
+#[test]
+fn test_my_filter() {
+ let t = MyFilterTemplate { s: "foo" };
+ assert_eq!(t.render().unwrap(), "faa");
+}