#[macro_use] extern crate askama; use askama::Template; #[derive(Template)] #[template(path = "filters.html")] struct TestTemplate { strvar: String, } #[test] fn filter_escape() { let s = TestTemplate { strvar: "my is unsafe & should be escaped".to_string(), }; assert_eq!(s.render().unwrap(), "my <html> is unsafe & should be escaped"); } #[derive(Template)] #[template(path = "format.html")] struct FormatTemplate<'a> { var: &'a str, } #[test] fn filter_format() { let t = FormatTemplate { var: "formatted" }; assert_eq!(t.render().unwrap(), "\"formatted\""); }