mirror of https://github.com/rwf2/Rocket.git
Update 'handlebars' to 1.0.
This commit is contained in:
parent
cee3bbca30
commit
49365d5fdf
|
@ -33,8 +33,8 @@ serde_json = { version = "1.0", optional = true }
|
||||||
rmp-serde = { version = "^0.13", optional = true }
|
rmp-serde = { version = "^0.13", optional = true }
|
||||||
|
|
||||||
# Templating dependencies only.
|
# Templating dependencies only.
|
||||||
handlebars = { version = "0.32", optional = true }
|
handlebars = { version = "1.0", optional = true }
|
||||||
glob = { version = "^0.2", optional = true }
|
glob = { version = "0.2", optional = true }
|
||||||
tera = { version = "0.11", optional = true }
|
tera = { version = "0.11", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -11,7 +11,7 @@ use rocket::Request;
|
||||||
use rocket::response::Redirect;
|
use rocket::response::Redirect;
|
||||||
use rocket_contrib::{Template, handlebars};
|
use rocket_contrib::{Template, handlebars};
|
||||||
|
|
||||||
use handlebars::{Helper, Handlebars, RenderContext, RenderError, JsonRender};
|
use handlebars::{Helper, Handlebars, Context, RenderContext, Output, HelperResult, JsonRender};
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct TemplateContext {
|
struct TemplateContext {
|
||||||
|
@ -54,9 +54,17 @@ fn not_found(req: &Request) -> Template {
|
||||||
Template::render("error/404", &map)
|
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) {
|
if let Some(param) = h.param(0) {
|
||||||
write!(rc.writer, "<b><i>{}</i></b>", param.value().render())?;
|
out.write("<b><i>")?;
|
||||||
|
out.write(¶m.value().render())?;
|
||||||
|
out.write("</b></i>")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in New Issue