Skip to content

Commit

Permalink
Auto merge of #3791 - sunng87:port-handlebars-to-serde, r=alexcrichton
Browse files Browse the repository at this point in the history
Use serde type system for handlebars

This will help cargo to drop rustc_serialize as dependency (#3682). Handlebars actually supports using serde_json as its type system instead of rustc_serialize. And I'm planning to drop rustc_serialize in future releases.
  • Loading branch information
bors committed Mar 3, 2017
2 parents a226b3c + 72d0a72 commit 5db6d64
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion 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 @@ -28,7 +28,7 @@ fs2 = "0.4"
git2 = "0.6"
git2-curl = "0.7"
glob = "0.2"
handlebars = "0.25"
handlebars = { version = "0.25", features = ["serde_type", "partial4"], default-features = false }
libc = "0.2"
libgit2-sys = "0.6"
log = "0.3"
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/util/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn toml_escape_helper(h: &Helper,
_: &Handlebars,
rc: &mut RenderContext) -> Result<(), RenderError> {
if let Some(param) = h.param(0) {
let txt = param.value().as_string().unwrap_or("").to_owned();
let txt = param.value().as_str().unwrap_or("").to_owned();
let rendered = format!("{}", toml::Value::String(txt));
try!(rc.writer.write_all(rendered.into_bytes().as_ref()));
}
Expand All @@ -30,7 +30,7 @@ pub fn html_escape_helper(h: &Helper,
_: &Handlebars,
rc: &mut RenderContext) -> Result<(), RenderError> {
if let Some(param) = h.param(0) {
let rendered = html_escape(param.value().as_string().unwrap_or(""));
let rendered = html_escape(param.value().as_str().unwrap_or(""));
try!(rc.writer.write_all(rendered.into_bytes().as_ref()));
}
Ok(())
Expand Down

0 comments on commit 5db6d64

Please sign in to comment.