summaryrefslogtreecommitdiffstats
path: root/vendor/handlebars/src/helpers/helper_if.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:03:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:03:36 +0000
commit17d40c6057c88f4c432b0d7bac88e1b84cb7e67f (patch)
tree3f66c4a5918660bb8a758ab6cda5ff8ee4f6cdcd /vendor/handlebars/src/helpers/helper_if.rs
parentAdding upstream version 1.64.0+dfsg1. (diff)
downloadrustc-17d40c6057c88f4c432b0d7bac88e1b84cb7e67f.tar.xz
rustc-17d40c6057c88f4c432b0d7bac88e1b84cb7e67f.zip
Adding upstream version 1.65.0+dfsg1.upstream/1.65.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/handlebars/src/helpers/helper_if.rs')
-rw-r--r--vendor/handlebars/src/helpers/helper_if.rs40
1 files changed, 39 insertions, 1 deletions
diff --git a/vendor/handlebars/src/helpers/helper_if.rs b/vendor/handlebars/src/helpers/helper_if.rs
index 5a6e42fc0..342c74567 100644
--- a/vendor/handlebars/src/helpers/helper_if.rs
+++ b/vendor/handlebars/src/helpers/helper_if.rs
@@ -36,7 +36,7 @@ impl HelperDef for IfHelper {
let tmpl = if value { h.template() } else { h.inverse() };
match tmpl {
- Some(ref t) => t.render(r, ctx, rc, out),
+ Some(t) => t.render(r, ctx, rc, out),
None => Ok(()),
}
}
@@ -137,6 +137,12 @@ mod test {
);
assert_eq!(
+ "yes\r\n",
+ hbs.render_template("{{#if a}}\r\nyes\r\n{{/if}}\r\n", &json!({"a": true}))
+ .unwrap()
+ );
+
+ assert_eq!(
"x\ny",
hbs.render_template("{{#if a}}x{{/if}}\ny", &json!({"a": true}))
.unwrap()
@@ -147,5 +153,37 @@ mod test {
hbs.render_template("{{#if a}}\nx\n{{^}}\ny\n{{/if}}\nz", &json!({"a": false}))
.unwrap()
);
+
+ assert_eq!(
+ r#"yes
+ foo
+ bar
+ baz"#,
+ hbs.render_template(
+ r#"yes
+ {{#if true}}
+ foo
+ bar
+ {{/if}}
+ baz"#,
+ &json!({})
+ )
+ .unwrap()
+ );
+
+ assert_eq!(
+ r#" foo
+ bar
+ baz"#,
+ hbs.render_template(
+ r#" {{#if true}}
+ foo
+ bar
+ {{/if}}
+ baz"#,
+ &json!({})
+ )
+ .unwrap()
+ );
}
}