aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests
diff options
context:
space:
mode:
Diffstat (limited to 'testing/tests')
-rw-r--r--testing/tests/filters.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs
index ca5e08d..5ddd8c5 100644
--- a/testing/tests/filters.rs
+++ b/testing/tests/filters.rs
@@ -49,6 +49,11 @@ mod filters {
pub fn myfilter(s: &str) -> ::askama::Result<String> {
Ok(s.replace("oo", "aa").to_string())
}
+ // for test_nested_filter_ref
+ pub fn mytrim(s: &::std::fmt::Display) -> ::askama::Result<String> {
+ let s = format!("{}", s);
+ Ok(s.trim().to_owned())
+ }
}
#[test]
@@ -110,3 +115,16 @@ fn test_json() {
}"#
);
}
+
+
+#[derive(Template)]
+#[template(source = "{{ x|mytrim|safe }}", ext = "html")]
+struct NestedFilterTemplate {
+ x: String,
+}
+
+#[test]
+fn test_nested_filter_ref() {
+ let t = NestedFilterTemplate { x: " floo & bar".to_string() };
+ assert_eq!(t.render().unwrap(), "floo & bar");
+}