Skip to content

Commit

Permalink
Merge pull request #1130 from sunng87/feature/handlebars-3.0
Browse files Browse the repository at this point in the history
Update handlebars to 3.0
  • Loading branch information
ehuss authored Mar 9, 2020
2 parents fd56a53 + 1947f8c commit 44c3213
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 32 deletions.
24 changes: 7 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ chrono = "0.4"
clap = "2.24"
env_logger = "0.6"
error-chain = "0.12"
handlebars = { version = "2.0", default-features = false, features = ["no_dir_source"] }
handlebars = "3.0"
itertools = "0.8"
lazy_static = "1.0"
log = "0.4"
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/html_handlebars/hbs_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"toc",
Box::new(helpers::toc::RenderToc {
Expand Down Expand Up @@ -705,7 +705,7 @@ fn partition_source(s: &str) -> (String, String) {
}

struct RenderItemContext<'a> {
handlebars: &'a Handlebars,
handlebars: &'a Handlebars<'a>,
destination: PathBuf,
data: serde_json::Map<String, serde_json::Value>,
is_index: bool,
Expand Down
16 changes: 8 additions & 8 deletions src/renderer/html_handlebars/helpers/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Target {

fn find_chapter(
ctx: &Context,
rc: &mut RenderContext<'_>,
rc: &mut RenderContext<'_, '_>,
target: Target,
) -> Result<Option<StringMap>, RenderError> {
debug!("Get data from context");
Expand Down Expand Up @@ -108,9 +108,9 @@ fn find_chapter(

fn render(
_h: &Helper<'_, '_>,
r: &Handlebars,
r: &Handlebars<'_>,
ctx: &Context,
rc: &mut RenderContext<'_>,
rc: &mut RenderContext<'_, '_>,
out: &mut dyn Output,
chapter: &StringMap,
) -> Result<(), RenderError> {
Expand Down Expand Up @@ -150,7 +150,7 @@ fn render(
_h.template()
.ok_or_else(|| RenderError::new("Error with the handlebars template"))
.and_then(|t| {
let mut local_rc = rc.new_for_block();
let mut local_rc = rc.clone();
let local_ctx = Context::wraps(&context)?;
t.render(r, &local_ctx, &mut local_rc, out)
})?;
Expand All @@ -160,9 +160,9 @@ fn render(

pub fn previous(
_h: &Helper<'_, '_>,
r: &Handlebars,
r: &Handlebars<'_>,
ctx: &Context,
rc: &mut RenderContext<'_>,
rc: &mut RenderContext<'_, '_>,
out: &mut dyn Output,
) -> Result<(), RenderError> {
trace!("previous (handlebars helper)");
Expand All @@ -176,9 +176,9 @@ pub fn previous(

pub fn next(
_h: &Helper<'_, '_>,
r: &Handlebars,
r: &Handlebars<'_>,
ctx: &Context,
rc: &mut RenderContext<'_>,
rc: &mut RenderContext<'_, '_>,
out: &mut dyn Output,
) -> Result<(), RenderError> {
trace!("next (handlebars helper)");
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/html_handlebars/helpers/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError

pub fn theme_option(
h: &Helper<'_, '_>,
_r: &Handlebars,
_r: &Handlebars<'_>,
ctx: &Context,
rc: &mut RenderContext<'_>,
rc: &mut RenderContext<'_, '_>,
out: &mut dyn Output,
) -> Result<(), RenderError> {
trace!("theme_option (handlebars helper)");
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/html_handlebars/helpers/toc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ impl HelperDef for RenderToc {
fn call<'reg: 'rc, 'rc>(
&self,
_h: &Helper<'reg, 'rc>,
_r: &'reg Handlebars,
_r: &'reg Handlebars<'_>,
ctx: &'rc Context,
rc: &mut RenderContext<'reg>,
rc: &mut RenderContext<'reg, 'rc>,
out: &mut dyn Output,
) -> Result<(), RenderError> {
// get value from context data
Expand Down

0 comments on commit 44c3213

Please sign in to comment.