Skip to content

Merging partial context with hash, regression of partial context refactor #696

@sunng87

Description

@sunng87
          I'm not sure if this is within the scope of this pull request, but it seems that even with this fix, hash params in `this` are not iterated by `#each`. Here's how I tested that:
--- a/src/partial.rs
+++ b/src/partial.rs
@@ -754,5 +754,14 @@ outer third line",
         hbs.register_template_string("t2", t2).unwrap();
 
         assert_eq!("1", hbs.render("t2", &()).unwrap());
+
+        let t1 = "{{#each this}}{{@key}}:{{this}},{{/each}}";
+        let t2 = "{{> t1 a=1}}";
+
+        let mut hbs = Registry::new();
+        hbs.register_template_string("t1", t1).unwrap();
+        hbs.register_template_string("t2", t2).unwrap();
+
+        assert_eq!("a:1,", hbs.render("t2", &()).unwrap());
     }
 }

(Same problem occurs when using block param syntax, e.g. {{#each this as |value key|}}{{key}}:{{value}},{{/each}}).

It turns out this is a recent regression—it works in handlebars-rust v6.3.0 but not v6.3.1 (it also works in handlebars.js). Perhaps it was a side effect of #694?

Please let me know if you'd like me to file a separate issue about this.

Originally posted by @mkantor in #695 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions