Add '.tera' extension to default Tera escapes.

This commit is contained in:
Joel Roller 2016-12-28 16:45:41 -06:00 committed by Sergio Benitez
parent ab94e344b4
commit 8deac6dba9
1 changed files with 7 additions and 1 deletions

View File

@ -8,7 +8,13 @@ use super::{TemplateInfo, TEMPLATE_DIR};
lazy_static! { lazy_static! {
static ref TERA: Result<tera::Tera, String> = { static ref TERA: Result<tera::Tera, String> = {
let path: PathBuf = [&*TEMPLATE_DIR, "**", "*.tera"].iter().collect(); let path: PathBuf = [&*TEMPLATE_DIR, "**", "*.tera"].iter().collect();
tera::Tera::new(path.to_str().unwrap()).map_err(|e| format!("{:?}", e)) let ext = [".html.tera", ".htm.tera", ".xml.tera", ".html", ".htm", ".xml"];
tera::Tera::new(path.to_str().unwrap())
.map(|mut tera| {
tera.autoescape_on(ext.to_vec());
tera
})
.map_err(|e| format!("{:?}", e))
}; };
} }