Update 'handlebars' to 1.0.

This commit is contained in:
Sergio Benitez 2018-07-22 02:25:55 -07:00
parent cee3bbca30
commit 49365d5fdf
2 changed files with 13 additions and 5 deletions

View File

@ -33,8 +33,8 @@ serde_json = { version = "1.0", optional = true }
rmp-serde = { version = "^0.13", optional = true }
# Templating dependencies only.
handlebars = { version = "0.32", optional = true }
glob = { version = "^0.2", optional = true }
handlebars = { version = "1.0", optional = true }
glob = { version = "0.2", optional = true }
tera = { version = "0.11", optional = true }
[dev-dependencies]

View File

@ -11,7 +11,7 @@ use rocket::Request;
use rocket::response::Redirect;
use rocket_contrib::{Template, handlebars};
use handlebars::{Helper, Handlebars, RenderContext, RenderError, JsonRender};
use handlebars::{Helper, Handlebars, Context, RenderContext, Output, HelperResult, JsonRender};
#[derive(Serialize)]
struct TemplateContext {
@ -54,9 +54,17 @@ fn not_found(req: &Request) -> Template {
Template::render("error/404", &map)
}
fn wow_helper(h: &Helper, _: &Handlebars, rc: &mut RenderContext) -> Result<(), RenderError> {
fn wow_helper(
h: &Helper,
_: &Handlebars,
_: &Context,
_: &mut RenderContext,
out: &mut Output
) -> HelperResult {
if let Some(param) = h.param(0) {
write!(rc.writer, "<b><i>{}</i></b>", param.value().render())?;
out.write("<b><i>")?;
out.write(&param.value().render())?;
out.write("</b></i>")?;
}
Ok(())