Skip to content

Commit 0aad658

Browse files
committed
Upgrade handlebars to 0.25.
1 parent 875a8ab commit 0aad658

File tree

4 files changed

+91
-20
lines changed

4 files changed

+91
-20
lines changed

Cargo.lock

Lines changed: 83 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fs2 = "0.3"
2828
git2 = "0.6"
2929
git2-curl = "0.7"
3030
glob = "0.2"
31-
handlebars = "0.20"
31+
handlebars = "0.25"
3232
libc = "0.2"
3333
libgit2-sys = "0.6"
3434
log = "0.3"

src/cargo/ops/cargo_new.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use git2::Config as GitConfig;
88

99
use term::color::BLACK;
1010

11-
use handlebars::{Handlebars, Context, no_escape};
11+
use handlebars::{Handlebars, no_escape};
1212
use tempdir::TempDir;
1313

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

520-
try!(handlebars.template_renderw(&template_str, &Context::wraps(&data), &mut dest_file)
520+
try!(handlebars.template_renderw(&template_str, &data, &mut dest_file)
521521
.chain_error(|| {
522522
human(format!("Failed to render template for file: {}", dest_path.display()))
523523
}))

src/cargo/util/template.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::io::{Read};
55
use util::{CargoResult, human, ChainError};
66
use url::Url;
77

8-
use handlebars::{Context, Helper, Handlebars, RenderContext, RenderError, html_escape};
8+
use handlebars::{Helper, Handlebars, RenderContext, RenderError, html_escape};
99
use tempdir::TempDir;
1010
use toml;
1111

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

2928
/// html_escape_helper escapes strings in templates using html escaping rules.
30-
pub fn html_escape_helper(_: &Context,
31-
h: &Helper,
29+
pub fn html_escape_helper(h: &Helper,
3230
_: &Handlebars,
3331
rc: &mut RenderContext) -> Result<(), RenderError> {
3432
if let Some(param) = h.param(0) {
@@ -170,7 +168,8 @@ mod test {
170168
handlebars.register_helper("toml-escape", Box::new(toml_escape_helper));
171169
let mut data = BTreeMap::new();
172170
data.insert("name".to_owned(), "\"Iron\" Mike Tyson".to_owned());
173-
let result = handlebars.template_render("Hello, {{#toml-escape name}}{{/toml-escape}}", &data).unwrap();
171+
let template_string = r#"Hello, {{#toml-escape name}}{{/toml-escape}}"#;
172+
let result = handlebars.template_render(template_string, &data).unwrap();
174173
assert_eq!(result, "Hello, \"\\\"Iron\\\" Mike Tyson\"");
175174
}
176175

0 commit comments

Comments
 (0)