aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-04-17 17:16:24 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-04-17 17:16:24 +0200
commit02266bed683080e6412c337251d69df23b5da3c6 (patch)
treef71c54723da1c4e3592c230ed5e7fa7fbab5de6d
parent6f0739eedbc0582ee713c628374bf4b88e34c9ae (diff)
downloadaskama-02266bed683080e6412c337251d69df23b5da3c6.tar.gz
askama-02266bed683080e6412c337251d69df23b5da3c6.tar.bz2
askama-02266bed683080e6412c337251d69df23b5da3c6.zip
Add test for nested filters with references (see #76)
Diffstat (limited to '')
-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");
+}