mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 15:25:19 +00:00
Add test for nested filters with references (see #76)
This commit is contained in:
parent
6f0739eedb
commit
02266bed68
@ -49,6 +49,11 @@ mod filters {
|
|||||||
pub fn myfilter(s: &str) -> ::askama::Result<String> {
|
pub fn myfilter(s: &str) -> ::askama::Result<String> {
|
||||||
Ok(s.replace("oo", "aa").to_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]
|
#[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");
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user