Skip to content

Commit 44c3213

Browse files
authored
Merge pull request #1130 from sunng87/feature/handlebars-3.0
Update handlebars to 3.0
2 parents fd56a53 + 1947f8c commit 44c3213

File tree

6 files changed

+22
-32
lines changed

6 files changed

+22
-32
lines changed

Cargo.lock

+7-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ chrono = "0.4"
2020
clap = "2.24"
2121
env_logger = "0.6"
2222
error-chain = "0.12"
23-
handlebars = { version = "2.0", default-features = false, features = ["no_dir_source"] }
23+
handlebars = "3.0"
2424
itertools = "0.8"
2525
lazy_static = "1.0"
2626
log = "0.4"

src/renderer/html_handlebars/hbs_renderer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl HtmlHandlebars {
212212
);
213213
}
214214

215-
fn register_hbs_helpers(&self, handlebars: &mut Handlebars, html_config: &HtmlConfig) {
215+
fn register_hbs_helpers(&self, handlebars: &mut Handlebars<'_>, html_config: &HtmlConfig) {
216216
handlebars.register_helper(
217217
"toc",
218218
Box::new(helpers::toc::RenderToc {
@@ -705,7 +705,7 @@ fn partition_source(s: &str) -> (String, String) {
705705
}
706706

707707
struct RenderItemContext<'a> {
708-
handlebars: &'a Handlebars,
708+
handlebars: &'a Handlebars<'a>,
709709
destination: PathBuf,
710710
data: serde_json::Map<String, serde_json::Value>,
711711
is_index: bool,

src/renderer/html_handlebars/helpers/navigation.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl Target {
4646

4747
fn find_chapter(
4848
ctx: &Context,
49-
rc: &mut RenderContext<'_>,
49+
rc: &mut RenderContext<'_, '_>,
5050
target: Target,
5151
) -> Result<Option<StringMap>, RenderError> {
5252
debug!("Get data from context");
@@ -108,9 +108,9 @@ fn find_chapter(
108108

109109
fn render(
110110
_h: &Helper<'_, '_>,
111-
r: &Handlebars,
111+
r: &Handlebars<'_>,
112112
ctx: &Context,
113-
rc: &mut RenderContext<'_>,
113+
rc: &mut RenderContext<'_, '_>,
114114
out: &mut dyn Output,
115115
chapter: &StringMap,
116116
) -> Result<(), RenderError> {
@@ -150,7 +150,7 @@ fn render(
150150
_h.template()
151151
.ok_or_else(|| RenderError::new("Error with the handlebars template"))
152152
.and_then(|t| {
153-
let mut local_rc = rc.new_for_block();
153+
let mut local_rc = rc.clone();
154154
let local_ctx = Context::wraps(&context)?;
155155
t.render(r, &local_ctx, &mut local_rc, out)
156156
})?;
@@ -160,9 +160,9 @@ fn render(
160160

161161
pub fn previous(
162162
_h: &Helper<'_, '_>,
163-
r: &Handlebars,
163+
r: &Handlebars<'_>,
164164
ctx: &Context,
165-
rc: &mut RenderContext<'_>,
165+
rc: &mut RenderContext<'_, '_>,
166166
out: &mut dyn Output,
167167
) -> Result<(), RenderError> {
168168
trace!("previous (handlebars helper)");
@@ -176,9 +176,9 @@ pub fn previous(
176176

177177
pub fn next(
178178
_h: &Helper<'_, '_>,
179-
r: &Handlebars,
179+
r: &Handlebars<'_>,
180180
ctx: &Context,
181-
rc: &mut RenderContext<'_>,
181+
rc: &mut RenderContext<'_, '_>,
182182
out: &mut dyn Output,
183183
) -> Result<(), RenderError> {
184184
trace!("next (handlebars helper)");

src/renderer/html_handlebars/helpers/theme.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError
22

33
pub fn theme_option(
44
h: &Helper<'_, '_>,
5-
_r: &Handlebars,
5+
_r: &Handlebars<'_>,
66
ctx: &Context,
7-
rc: &mut RenderContext<'_>,
7+
rc: &mut RenderContext<'_, '_>,
88
out: &mut dyn Output,
99
) -> Result<(), RenderError> {
1010
trace!("theme_option (handlebars helper)");

src/renderer/html_handlebars/helpers/toc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ impl HelperDef for RenderToc {
1616
fn call<'reg: 'rc, 'rc>(
1717
&self,
1818
_h: &Helper<'reg, 'rc>,
19-
_r: &'reg Handlebars,
19+
_r: &'reg Handlebars<'_>,
2020
ctx: &'rc Context,
21-
rc: &mut RenderContext<'reg>,
21+
rc: &mut RenderContext<'reg, 'rc>,
2222
out: &mut dyn Output,
2323
) -> Result<(), RenderError> {
2424
// get value from context data

0 commit comments

Comments
 (0)