-
Notifications
You must be signed in to change notification settings - Fork 70
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
Comparison filters (@eq
, @ne
, etc.) should accept undefined as a key.
#59
Comments
+1, this seems really broken right now. It will probably just be a fix to the filter function. |
I would use
|
I'd say that is a work around, but it'd have to be more like this:
The problem gets a lot worse the bigger the markup that would replace "myOptionalCount is not 0" gets. |
evaluates to false when myOptionalCount is 0 so I don't think you need the |
Good point. A better value to illustrate the bug would be one that is greater than 0. |
example how to solve this problem with @js helper |
At first glance it seems reasonable to output
Another thing to keep in mind is that fixing this would be somewhat backward incompatible. If template relied on nothing being output previously, it would require a code fix (to execute comparison filter only when key is defined). Relying on this behavior does not seem like a good practice though and I'm in favor of fixing this. We should do a minor version bump with this fix though. |
We should distinguish between cases where no |
…et but resolves to undefined. Previously, if a helper's key parameter was set, but the Dust variable to which it pointed did not exist, the helper would immediately abort. However, this breaks cases especially for {@ne} in which it would be completely valid if the key did not exist. The helper will still fail to execute if a key parameter is not passed. However, if the parameter resolves to an undefined variable, it will now execute. This is a non-backwards-compatible change. Closes LinkedInAttic#59.
…et but resolves to undefined. Previously, if a helper's key parameter was set, but the Dust variable to which it pointed did not exist, the helper would immediately abort. However, this breaks cases especially for {@ne} in which it would be completely valid if the key did not exist. The helper will still fail to execute if a key parameter is not passed. However, if the parameter resolves to an undefined variable, it will now execute. This is a non-backwards-compatible change. Closes LinkedInAttic#59.
If I have a template where a certain key in the JSON may or may not be defined, and I use a comparison filter, the body and else blocks are skipped.
Example JSON
Example template
Example output
Expected output
The text was updated successfully, but these errors were encountered: