Update tera

This commit is contained in:
Vincent Prouillet 2019-10-20 19:08:01 +01:00
parent 6149fd17e1
commit 243702e2c2
10 changed files with 200 additions and 197 deletions

373
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"] authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
[dependencies] [dependencies]
tera = "1.0.0-beta.10" tera = "1.0.0-beta.17"
toml = "0.5" toml = "0.5"
image = "0.22" image = "0.22"
syntect = "=3.2.0" syntect = "=3.2.0"

View file

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"] authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
[dependencies] [dependencies]
tera = "1.0.0-beta.10" tera = "1.0.0-beta.17"
chrono = "0.4" chrono = "0.4"
serde = "1" serde = "1"
serde_derive = "1" serde_derive = "1"

View file

@ -6,7 +6,7 @@ authors = ["Vojtěch Král <vojtech@kral.hk>"]
[dependencies] [dependencies]
lazy_static = "1" lazy_static = "1"
regex = "1.0" regex = "1.0"
tera = "1.0.0-beta.10" tera = "1.0.0-beta.17"
image = "0.22" image = "0.22"
rayon = "1" rayon = "1"

View file

@ -7,7 +7,7 @@ authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
slotmap = "0.4" slotmap = "0.4"
rayon = "1" rayon = "1"
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
tera = "1.0.0-beta.10" tera = "1.0.0-beta.17"
serde = "1" serde = "1"
serde_derive = "1" serde_derive = "1"
slug = "0.1" slug = "0.1"

View file

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"] authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
[dependencies] [dependencies]
tera = "1.0.0-beta.10" tera = "1.0.0-beta.17"
glob = "0.3" glob = "0.3"
rayon = "1" rayon = "1"
serde = "1" serde = "1"

View file

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"] authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
[dependencies] [dependencies]
tera = "1.0.0-beta.10" tera = "1.0.0-beta.17"
base64 = "0.10" base64 = "0.10"
lazy_static = "1" lazy_static = "1"
pulldown-cmark = "0.6" pulldown-cmark = "0.6"

View file

@ -69,6 +69,6 @@ pub fn render_redirect_template(url: &str, tera: &Tera) -> Result<String> {
let mut context = Context::new(); let mut context = Context::new();
context.insert("url", &url); context.insert("url", &url);
tera.render("internal/alias.html", context) tera.render("internal/alias.html", &context)
.map_err(|e| Error::chain(format!("Failed to render alias for '{}'", url), e)) .map_err(|e| Error::chain(format!("Failed to render alias for '{}'", url), e))
} }

View file

@ -5,7 +5,7 @@ authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
[dependencies] [dependencies]
errors = { path = "../errors" } errors = { path = "../errors" }
tera = "1.0.0-beta.10" tera = "1.0.0-beta.17"
unicode-segmentation = "1.2" unicode-segmentation = "1.2"
walkdir = "2" walkdir = "2"
toml = "0.5" toml = "0.5"

View file

@ -11,7 +11,7 @@ macro_rules! render_default_tpl {
let mut context = Context::new(); let mut context = Context::new();
context.insert("filename", $filename); context.insert("filename", $filename);
context.insert("url", $url); context.insert("url", $url);
Tera::one_off(DEFAULT_TPL, context, true).map_err(std::convert::Into::into) Tera::one_off(DEFAULT_TPL, &context, true).map_err(std::convert::Into::into)
}}; }};
} }
@ -27,21 +27,21 @@ pub fn render_template(
) -> Result<String> { ) -> Result<String> {
// check if it is in the templates // check if it is in the templates
if tera.templates.contains_key(name) { if tera.templates.contains_key(name) {
return tera.render(name, context).map_err(std::convert::Into::into); return tera.render(name, &context).map_err(std::convert::Into::into);
} }
// check if it is part of a theme // check if it is part of a theme
if let Some(ref t) = *theme { if let Some(ref t) = *theme {
let theme_template_name = format!("{}/templates/{}", t, name); let theme_template_name = format!("{}/templates/{}", t, name);
if tera.templates.contains_key(&theme_template_name) { if tera.templates.contains_key(&theme_template_name) {
return tera.render(&theme_template_name, context).map_err(std::convert::Into::into); return tera.render(&theme_template_name, &context).map_err(std::convert::Into::into);
} }
} }
// check if it is part of ZOLA_TERA defaults // check if it is part of ZOLA_TERA defaults
let default_name = format!("__zola_builtins/{}", name); let default_name = format!("__zola_builtins/{}", name);
if tera.templates.contains_key(&default_name) { if tera.templates.contains_key(&default_name) {
return tera.render(&default_name, context).map_err(std::convert::Into::into); return tera.render(&default_name, &context).map_err(std::convert::Into::into);
} }
// maybe it's a default one? // maybe it's a default one?