diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:06:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:06:37 +0000 |
commit | 246f239d9f40f633160f0c18f87a20922d4e77bb (patch) | |
tree | 5a88572663584b3d4d28e5a20e10abab1be40884 /vendor/handlebars/tests/escape.rs | |
parent | Releasing progress-linux version 1.64.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-246f239d9f40f633160f0c18f87a20922d4e77bb.tar.xz rustc-246f239d9f40f633160f0c18f87a20922d4e77bb.zip |
Merging debian version 1.65.0+dfsg1-2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/handlebars/tests/escape.rs')
-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() + ); +} |