mirror of https://github.com/rwf2/Rocket.git
minimize logic in tera autoescape config closure
Incorporate feedback from SergioBenitez: define extension list outside closure and remove unnecessary comment
This commit is contained in:
parent
5a99e92e14
commit
5b1186a530
|
@ -8,15 +8,12 @@ use super::{TemplateInfo, TEMPLATE_DIR};
|
|||
lazy_static! {
|
||||
static ref TERA: Result<tera::Tera, String> = {
|
||||
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))
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue