Rocket

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 49365d5fdf29ba4694f4861d4f3410f34851aaa1
parent cee3bbca30bea697ea9e8e4c0e32e27fda49cbc6
Author: Sergio Benitez <sb@sergio.bz>
Date:   Sun, 22 Jul 2018 02:25:55 -0700

Update 'handlebars' to 1.0.

Diffstat:
Mcontrib/lib/Cargo.toml | 4++--
Mexamples/handlebars_templates/src/main.rs | 14+++++++++++---
2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/contrib/lib/Cargo.toml b/contrib/lib/Cargo.toml @@ -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] diff --git a/examples/handlebars_templates/src/main.rs b/examples/handlebars_templates/src/main.rs @@ -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(())