patternlab-node icon indicating copy to clipboard operation
patternlab-node copied to clipboard

[Handlebars] Inconsistent data access when leveraging sibling JSON + partial blocks

Open acarnwath opened this issue 2 years ago • 0 comments

When sibling JSON is provided, when leveraging {{@partial-block}}, {{this}} no longer exists consistently.

This is a problem because when leveraging a Handlebars Helper that is not expecting undefined to be passed in, it breaks my build. However, it appears to ultimately render correctly (with the data as expected) if I remove the helper.

For example, I have 2 patterns.

partial-test.hbs

{{> @partial-block }}

test.hbs:

{{log this}} <- outputs the global data

{{#> molecules-partial-test}}
  {{log this}} <- expected to output the global data as well
{{/molecules-partial-test}}

This works as expected... then, when I add in sibling JSON file, I get some weird behavior

test.json

  { "foo": "bar" }

Now, in the console, I see undefined, and then { "foo": "bar" } combined with the global data (from _data/*.json).

The same thing happens if I make a pseudo pattern:

test~pseudo.json

  { "hello": "world" }

Now, in the console (with both JSON files), I see undefined, undefined, and then { "foo": "bar" } and { "hello": "world" } combined with the global data (from _data/*.json).

acarnwath avatar Dec 01 '23 20:12 acarnwath