-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Strict mode shouldn't be enforced in conditionals #1063
Comments
There is nothing special about We could potentially not throw for missing variables for any helper variable reference, instead leaving those checks to the helper, but I'm hesitant to make such a change without hearing from users of this feature. @nzakas you requested this initially, any opinions? |
Is it the |
Right now the throw is done on the reference to the variable, similar to Javascript behavior when referencing an undeclared global without doing a
Where strict is this method. The proposed change would be for strict checking to occur for all of these references to foo, but nothing else:
But these
The helper would not be able to differentiate between explicitly undefined and missing as they would just have the |
This allows for `{{helper foo}}` to still operate under strict mode when `foo` is not defined on the context. This allows helpers to perform whatever existence checks they please so patterns like `{{#if foo}}{{foo}}{{/if}}` can be used to protect against missing values. Fixes handlebars-lang#1063
Currently:
I definitely expected this to not be the case (you should be able to explicitly protect against missing values, IMO)!
The text was updated successfully, but these errors were encountered: