diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-04-17 17:16:24 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-04-17 17:16:24 +0200 |
commit | 02266bed683080e6412c337251d69df23b5da3c6 (patch) | |
tree | f71c54723da1c4e3592c230ed5e7fa7fbab5de6d | |
parent | 6f0739eedbc0582ee713c628374bf4b88e34c9ae (diff) | |
download | askama-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.rs | 18 |
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"); +} |