Skip to content

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

Open
@acarnwath

Description

@acarnwath

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions