From 76b99dfc7db5dea9467b90c0cbc7289e811edf9f Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 19 Apr 2018 14:32:19 +0200 Subject: [PATCH] Add test for filter in let statement --- testing/tests/filters.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs index 5ddd8c578..fc8c99f63 100644 --- a/testing/tests/filters.rs +++ b/testing/tests/filters.rs @@ -128,3 +128,25 @@ fn test_nested_filter_ref() { let t = NestedFilterTemplate { x: " floo & bar".to_string() }; assert_eq!(t.render().unwrap(), "floo & bar"); } + + +#[derive(Template)] +#[template(source = "{% let p = baz.print(foo.as_ref()) %}{{ p|upper }}", ext = "html")] +struct FilterLetFilterTemplate { + foo: String, + baz: Baz, +} + +struct Baz {} + +impl Baz { + fn print(&self, s: &str) -> String { + s.trim().to_owned() + } +} + +#[test] +fn test_filter_let_filter() { + let t = FilterLetFilterTemplate { foo: " bar ".to_owned(), baz: Baz {} }; + assert_eq!(t.render().unwrap(), "BAR"); +}