Merge pull request #1130 from sunng87/feature/handlebars-3.0

Update handlebars to 3.0
This commit is contained in:
Eric Huss 2020-03-08 18:54:39 -07:00 committed by GitHub
commit 44c3213f5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 32 deletions

24
Cargo.lock generated
View File

@ -399,26 +399,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "handlebars" name = "handlebars"
version = "2.0.2" version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "hashbrown"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "heck" name = "heck"
version = "0.3.1" version = "0.3.1"
@ -471,7 +462,7 @@ name = "humantime"
version = "1.3.0" version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -684,7 +675,7 @@ dependencies = [
"env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gitignore 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "gitignore 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"handlebars 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "handlebars 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"iron 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "iron 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1007,7 +998,7 @@ dependencies = [
[[package]] [[package]]
name = "quick-error" name = "quick-error"
version = "1.2.2" version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
@ -1734,8 +1725,7 @@ dependencies = [
"checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" "checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407"
"checksum gitignore 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f5beed3b526478bebc1dd164b7aa770ae709f918a7b978fcb4afdaf3bbee8dfd" "checksum gitignore 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f5beed3b526478bebc1dd164b7aa770ae709f918a7b978fcb4afdaf3bbee8dfd"
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
"checksum handlebars 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "91ef1ac30f2eaaa2b835fce73c57091cb6b9fc62b7eef285efbf980b0f20001b" "checksum handlebars 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bb959f7ef68cdfd3bf80efac8cc370942f6480400fee7e150b06dc0dd1ad806"
"checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353"
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
"checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" "checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120"
"checksum html5ever 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5ce65ac8028cf5a287a7dbf6c4e0a6cf2dcf022ed5b167a81bae66ebf599a8b7" "checksum html5ever 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5ce65ac8028cf5a287a7dbf6c4e0a6cf2dcf022ed5b167a81bae66ebf599a8b7"
@ -1800,7 +1790,7 @@ dependencies = [
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" "checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27"
"checksum pulldown-cmark 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1c205cc82214f3594e2d50686730314f817c67ffa80fe800cf0db78c3c2b9d9e" "checksum pulldown-cmark 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1c205cc82214f3594e2d50686730314f817c67ffa80fe800cf0db78c3c2b9d9e"
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"

View File

@ -20,7 +20,7 @@ chrono = "0.4"
clap = "2.24" clap = "2.24"
env_logger = "0.6" env_logger = "0.6"
error-chain = "0.12" error-chain = "0.12"
handlebars = { version = "2.0", default-features = false, features = ["no_dir_source"] } handlebars = "3.0"
itertools = "0.8" itertools = "0.8"
lazy_static = "1.0" lazy_static = "1.0"
log = "0.4" log = "0.4"

View File

@ -212,7 +212,7 @@ impl HtmlHandlebars {
); );
} }
fn register_hbs_helpers(&self, handlebars: &mut Handlebars, html_config: &HtmlConfig) { fn register_hbs_helpers(&self, handlebars: &mut Handlebars<'_>, html_config: &HtmlConfig) {
handlebars.register_helper( handlebars.register_helper(
"toc", "toc",
Box::new(helpers::toc::RenderToc { Box::new(helpers::toc::RenderToc {
@ -705,7 +705,7 @@ fn partition_source(s: &str) -> (String, String) {
} }
struct RenderItemContext<'a> { struct RenderItemContext<'a> {
handlebars: &'a Handlebars, handlebars: &'a Handlebars<'a>,
destination: PathBuf, destination: PathBuf,
data: serde_json::Map<String, serde_json::Value>, data: serde_json::Map<String, serde_json::Value>,
is_index: bool, is_index: bool,

View File

@ -46,7 +46,7 @@ impl Target {
fn find_chapter( fn find_chapter(
ctx: &Context, ctx: &Context,
rc: &mut RenderContext<'_>, rc: &mut RenderContext<'_, '_>,
target: Target, target: Target,
) -> Result<Option<StringMap>, RenderError> { ) -> Result<Option<StringMap>, RenderError> {
debug!("Get data from context"); debug!("Get data from context");
@ -108,9 +108,9 @@ fn find_chapter(
fn render( fn render(
_h: &Helper<'_, '_>, _h: &Helper<'_, '_>,
r: &Handlebars, r: &Handlebars<'_>,
ctx: &Context, ctx: &Context,
rc: &mut RenderContext<'_>, rc: &mut RenderContext<'_, '_>,
out: &mut dyn Output, out: &mut dyn Output,
chapter: &StringMap, chapter: &StringMap,
) -> Result<(), RenderError> { ) -> Result<(), RenderError> {
@ -150,7 +150,7 @@ fn render(
_h.template() _h.template()
.ok_or_else(|| RenderError::new("Error with the handlebars template")) .ok_or_else(|| RenderError::new("Error with the handlebars template"))
.and_then(|t| { .and_then(|t| {
let mut local_rc = rc.new_for_block(); let mut local_rc = rc.clone();
let local_ctx = Context::wraps(&context)?; let local_ctx = Context::wraps(&context)?;
t.render(r, &local_ctx, &mut local_rc, out) t.render(r, &local_ctx, &mut local_rc, out)
})?; })?;
@ -160,9 +160,9 @@ fn render(
pub fn previous( pub fn previous(
_h: &Helper<'_, '_>, _h: &Helper<'_, '_>,
r: &Handlebars, r: &Handlebars<'_>,
ctx: &Context, ctx: &Context,
rc: &mut RenderContext<'_>, rc: &mut RenderContext<'_, '_>,
out: &mut dyn Output, out: &mut dyn Output,
) -> Result<(), RenderError> { ) -> Result<(), RenderError> {
trace!("previous (handlebars helper)"); trace!("previous (handlebars helper)");
@ -176,9 +176,9 @@ pub fn previous(
pub fn next( pub fn next(
_h: &Helper<'_, '_>, _h: &Helper<'_, '_>,
r: &Handlebars, r: &Handlebars<'_>,
ctx: &Context, ctx: &Context,
rc: &mut RenderContext<'_>, rc: &mut RenderContext<'_, '_>,
out: &mut dyn Output, out: &mut dyn Output,
) -> Result<(), RenderError> { ) -> Result<(), RenderError> {
trace!("next (handlebars helper)"); trace!("next (handlebars helper)");

View File

@ -2,9 +2,9 @@ use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError
pub fn theme_option( pub fn theme_option(
h: &Helper<'_, '_>, h: &Helper<'_, '_>,
_r: &Handlebars, _r: &Handlebars<'_>,
ctx: &Context, ctx: &Context,
rc: &mut RenderContext<'_>, rc: &mut RenderContext<'_, '_>,
out: &mut dyn Output, out: &mut dyn Output,
) -> Result<(), RenderError> { ) -> Result<(), RenderError> {
trace!("theme_option (handlebars helper)"); trace!("theme_option (handlebars helper)");

View File

@ -16,9 +16,9 @@ impl HelperDef for RenderToc {
fn call<'reg: 'rc, 'rc>( fn call<'reg: 'rc, 'rc>(
&self, &self,
_h: &Helper<'reg, 'rc>, _h: &Helper<'reg, 'rc>,
_r: &'reg Handlebars, _r: &'reg Handlebars<'_>,
ctx: &'rc Context, ctx: &'rc Context,
rc: &mut RenderContext<'reg>, rc: &mut RenderContext<'reg, 'rc>,
out: &mut dyn Output, out: &mut dyn Output,
) -> Result<(), RenderError> { ) -> Result<(), RenderError> {
// get value from context data // get value from context data