summaryrefslogtreecommitdiffstats
path: root/vendor/handlebars/src/helpers/helper_if.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-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()
+ );
}
}