diff options
Diffstat (limited to '')
-rw-r--r-- | vendor/handlebars/tests/escape.rs | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/vendor/handlebars/tests/escape.rs b/vendor/handlebars/tests/escape.rs index 563ab76b9..4a737f5ce 100644 --- a/vendor/handlebars/tests/escape.rs +++ b/vendor/handlebars/tests/escape.rs @@ -3,7 +3,7 @@ extern crate handlebars; #[macro_use] extern crate serde_json; -use handlebars::{handlebars_helper, Handlebars}; +use handlebars::{handlebars_helper, no_escape, Handlebars}; #[test] fn test_escape_216() { @@ -41,3 +41,43 @@ fn test_string_no_escape_422() { .unwrap() ); } + +#[test] +fn test_string_whitespace_467() { + const TEMPLATE_UNQUOTED: &str = r#"{{#each synonyms}} + {{this.name}} => '{{this.sym}}', + {{/each}} +"#; + + let mut hbs = Handlebars::new(); + hbs.register_escape_fn(no_escape); + hbs.register_template_string("perl", TEMPLATE_UNQUOTED) + .unwrap(); + + let r = hbs + .render("perl", &json!({"synonyms": [{"name": "lt", "sym": "<"}]})) + .unwrap(); + assert_eq!(" lt => '<',\n", r); +} + +#[test] +fn test_triple_bracket_expression_471() { + let mut hbs = Handlebars::new(); + + handlebars_helper!(replace: |input: str| { + input.replace("\n", "<br/>") + }); + hbs.register_helper("replace", Box::new(replace)); + + assert_eq!( + "some<br/>path", + hbs.render_template("{{replace h}}", &json!({"h": "some\npath"})) + .unwrap() + ); + + assert_eq!( + "some<br/>path", + hbs.render_template("{{{replace h}}}", &json!({"h": "some\npath"})) + .unwrap() + ); +} |