Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update object.js - Inline use of JSONparse patch #342

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

34638a
Copy link

@34638a 34638a commented Feb 12, 2025

Add patch to allow for #JSONparse to be used as a inline helper.

*This is a feature parody patch to align use case with proposed change for JSONparseSafe helper. #341

Examples:
{{log (JSONparse '{"test":"variable"}')}}
{{log (lookup (JSONparse '{"test":{"validate":"variable"}}') "test")}}

What? Why?

To prevent this situation which makes code so much harder to maintain and reason with:

{{! Pretend at this layer there is a pagination object here }}

{{! Before}}
{{#JSONparse '{"test": "hello world!"}'}}
    {{#with this}}
        {{log test}}
        {{log ../../pagination}}
    {{/with}}
{{/JSONparse}}


{{! After}}
{{#with (JSONparse '{"test": "hello world!"}')}}
    {{log test}}
    {{log ../pagination}}
{{/with}}

This change removes a extra layer of context shifting ( ../ ) to access information about the context window.

How was it tested?

Local tests, modified local theme testing file.

cc @bigcommerce/storefront-team

Parody patch to align usecase with proposed change for `JSONparseSafe` helper.

Tests are the same as per JSONSafeParse.
Tests in PR comment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant