Skip to content

Commit

Permalink
Upgrade handlebars to 0.25.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehiggs committed Jan 31, 2017
1 parent 875a8ab commit 0aad658
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 20 deletions.
94 changes: 83 additions & 11 deletions 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.3"
git2 = "0.6"
git2-curl = "0.7"
glob = "0.2"
handlebars = "0.20"
handlebars = "0.25"
libc = "0.2"
libgit2-sys = "0.6"
log = "0.3"
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use git2::Config as GitConfig;

use term::color::BLACK;

use handlebars::{Handlebars, Context, no_escape};
use handlebars::{Handlebars, no_escape};
use tempdir::TempDir;

use core::Workspace;
Expand Down Expand Up @@ -517,7 +517,7 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> {
dest_path.display()))
}));

try!(handlebars.template_renderw(&template_str, &Context::wraps(&data), &mut dest_file)
try!(handlebars.template_renderw(&template_str, &data, &mut dest_file)
.chain_error(|| {
human(format!("Failed to render template for file: {}", dest_path.display()))
}))
Expand Down
11 changes: 5 additions & 6 deletions src/cargo/util/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::io::{Read};
use util::{CargoResult, human, ChainError};
use url::Url;

use handlebars::{Context, Helper, Handlebars, RenderContext, RenderError, html_escape};
use handlebars::{Helper, Handlebars, RenderContext, RenderError, html_escape};
use tempdir::TempDir;
use toml;

Expand All @@ -14,8 +14,7 @@ use toml;
/// So if 'name' is "foo \"bar\"" then:
/// {{name}} renders as 'foo "bar"'
/// {{#toml-escape name}} renders as '"foo \"bar\""'
pub fn toml_escape_helper(_: &Context,
h: &Helper,
pub fn toml_escape_helper(h: &Helper,
_: &Handlebars,
rc: &mut RenderContext) -> Result<(), RenderError> {
if let Some(param) = h.param(0) {
Expand All @@ -27,8 +26,7 @@ pub fn toml_escape_helper(_: &Context,
}

/// html_escape_helper escapes strings in templates using html escaping rules.
pub fn html_escape_helper(_: &Context,
h: &Helper,
pub fn html_escape_helper(h: &Helper,
_: &Handlebars,
rc: &mut RenderContext) -> Result<(), RenderError> {
if let Some(param) = h.param(0) {
Expand Down Expand Up @@ -170,7 +168,8 @@ mod test {
handlebars.register_helper("toml-escape", Box::new(toml_escape_helper));
let mut data = BTreeMap::new();
data.insert("name".to_owned(), "\"Iron\" Mike Tyson".to_owned());
let result = handlebars.template_render("Hello, {{#toml-escape name}}{{/toml-escape}}", &data).unwrap();
let template_string = r#"Hello, {{#toml-escape name}}{{/toml-escape}}"#;
let result = handlebars.template_render(template_string, &data).unwrap();
assert_eq!(result, "Hello, \"\\\"Iron\\\" Mike Tyson\"");
}

Expand Down

0 comments on commit 0aad658

Please sign in to comment.