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

Create typeof.js #340

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

Create typeof.js #340

wants to merge 1 commit into from

Conversation

34638a
Copy link

@34638a 34638a commented Feb 7, 2025

Add implementation of javascript "typeof".
Implementation is based on json.js call which will yield a inline string as a result.

Registration into helpers list is required if approved. https://github.com/bigcommerce/paper-handlebars/blob/master/helpers.js

What? Why?

Function to determine type of provided input regardless of what the inline result is for use in if statements, and inline object construction. eg. of using in JSON.Parse string {"value_type":"{{typeof variable}}"}.
This also has the side effect that it will prevent needed to serialise objects in no-js environments to determine flow state via CSS selectors.

[data-test-for-typeof="Number"] {
    display: hidden;
}

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof

How was it tested?

Not tested. Based off existing file json.js with output line returning typeof data instead of JSON.stringify(data).

cc @bigcommerce/storefront-team

Add implementation of javascript "typeof".
Implementation is based on json.js call which will yield a inline string as a result.

Registration into helpers list is required if approved.
https://github.com/bigcommerce/paper-handlebars/blob/master/helpers.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant