From 02266bed683080e6412c337251d69df23b5da3c6 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 17 Apr 2018 17:16:24 +0200 Subject: Add test for nested filters with references (see #76) --- testing/tests/filters.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'testing/tests') 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 { Ok(s.replace("oo", "aa").to_string()) } + // for test_nested_filter_ref + pub fn mytrim(s: &::std::fmt::Display) -> ::askama::Result { + 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"); +} -- cgit