summaryrefslogtreecommitdiffstats
path: root/vendor/handlebars/tests/helper_with_space.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/handlebars/tests/helper_with_space.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/handlebars/tests/helper_with_space.rs')
-rw-r--r--vendor/handlebars/tests/helper_with_space.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/handlebars/tests/helper_with_space.rs b/vendor/handlebars/tests/helper_with_space.rs
new file mode 100644
index 000000000..5a55ab122
--- /dev/null
+++ b/vendor/handlebars/tests/helper_with_space.rs
@@ -0,0 +1,36 @@
+use handlebars::*;
+use serde_json::json;
+
+fn dump<'reg, 'rc>(
+ h: &Helper<'reg, 'rc>,
+ _: &'reg Handlebars,
+ _: &Context,
+ _: &mut RenderContext,
+ out: &mut dyn Output,
+) -> Result<(), RenderError> {
+ assert_eq!(2, h.params().len());
+
+ let result = h
+ .params()
+ .iter()
+ .map(|p| p.value().render())
+ .collect::<Vec<String>>()
+ .join(", ");
+ out.write(&result)?;
+
+ Ok(())
+}
+
+#[test]
+fn test_helper_with_space_param() {
+ let mut r = Handlebars::new();
+ r.register_helper("echo", Box::new(dump));
+
+ let s = r
+ .render_template(
+ "Output: {{echo \"Mozilla Firefox\" \"Google Chrome\"}}",
+ &json!({}),
+ )
+ .unwrap();
+ assert_eq!(s, "Output: Mozilla Firefox, Google Chrome".to_owned());
+}