diff options
Diffstat (limited to 'testing')
| -rw-r--r-- | testing/tests/filters.rs | 19 | 
1 files changed, 19 insertions, 0 deletions
| diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs index 665e50d..524014e 100644 --- a/testing/tests/filters.rs +++ b/testing/tests/filters.rs @@ -30,3 +30,22 @@ fn filter_format() {      let t = FormatTemplate { var: "formatted" };      assert_eq!(t.render().unwrap(), "\"formatted\"");  } + + +#[derive(Template)] +#[template(source = "{{ s|myfilter }}")] +struct MyFilterTemplate<'a> { +    s: &'a str, +} + +mod filters { +    pub fn myfilter(s: &str) -> ::askama::Result<String> { +        Ok(s.replace("oo", "aa").to_string()) +    } +} + +#[test] +fn test_my_filter() { +    let t = MyFilterTemplate { s: "foo" }; +    assert_eq!(t.render().unwrap(), "faa"); +} | 
