Skip to content

Commit

Permalink
Add test for filter in let statement
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Apr 19, 2018
1 parent 248e74b commit 76b99df
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions testing/tests/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

0 comments on commit 76b99df

Please sign in to comment.