From 5b1186a530a86bbf3e8b21ada49df3cf2b0b4b01 Mon Sep 17 00:00:00 2001 From: Joel Roller Date: Wed, 28 Dec 2016 20:22:53 -0600 Subject: [PATCH] minimize logic in tera autoescape config closure Incorporate feedback from SergioBenitez: define extension list outside closure and remove unnecessary comment --- contrib/src/templates/tera_templates.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/contrib/src/templates/tera_templates.rs b/contrib/src/templates/tera_templates.rs index eebd55bf..75952cf5 100644 --- a/contrib/src/templates/tera_templates.rs +++ b/contrib/src/templates/tera_templates.rs @@ -8,15 +8,12 @@ use super::{TemplateInfo, TEMPLATE_DIR}; lazy_static! { static ref TERA: Result = { let path: PathBuf = [&*TEMPLATE_DIR, "**", "*.tera"].iter().collect(); + let escape_ext = [".html.tera", ".htm.tera", ".xml.tera", + ".html", ".htm", ".xml"]; tera::Tera::new(path.to_str().unwrap()) - .map(|mut t| { - t.autoescape_on(vec![ - // defaults with .tera extension - ".html.tera",".htm.tera",".xml.tera", - // keep tera default extensions - ".html",".htm",".xml" - ]); - t + .map(|mut tera| { + tera.autoescape_on(escape_ext.to_vec()); + tera }) .map_err(|e| format!("{:?}", e)) };