-
Notifications
You must be signed in to change notification settings - Fork 225
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
Revisit behaviour of undefined values #248
Comments
I'm in the "throw error if it doesn't exist" camp, but might be best to have this configurable. An issue might be that sometimes, you don't know if a property exists or not, and we have no way of knowing if the object Jinja has a whole bunch of |
Yes, this should be configurable to some degree. Though what do you mean "don't know if a property exists or not"? We can add |
Nah I mean for example:
|
By "may not exist" you mean "value of the property is In the first case, I think it should not through any exception by default and there should be a way to check for that at runtime, like The second case should by default result in the exception, but this can be softened via configuration. |
I think there may be multiple levels? And a
|
The same should actually apply to KVO, if we can't find property using recently introduced selector check - we should raise exception |
Current behavior of
Variable.resolve
when it encounters undefined values is IMO inconsistent with other kinds of errors, like an unknown filter, which results in an exception. Accessing undefined value, i.e.blog.uri
instead ofblog.url
results in the empty output instead of exception or JavaScript-like output "undefined" which can be confusing for users.Before #245 when resolving properties of collections unknown keys were simply skipped, resulting in
contacts.something.0
render the same way ascontacts.0
instead of raising an exception or returningnil
. With #245 resolving arrays and string properties was refactored so it will now returnnil
. But the issue is still present for dictionaries.Expected behavior:
nil
values can still result in an empty string or can be configured to render "undefined" or anything else per user choice, i.e. "nil"/"null"The text was updated successfully, but these errors were encountered: