Closed James4Ever0 closed 8 months ago
I don't plan on adding this to Jinja core. This doesn't match the general behavior of other Undefined
types. If you think it would be generally useful to others, you can release it as an extension on PyPI, there's nothing required from Jinja itself for this.
I will release some extension for this.
The reason I do this is because in Python we do not have such concept of undefined
and it should be turned off from the very beginning, as default. This concept is most likely in Javascript, where lawlessness is up to a whole new level.
I don't plan on adding this to Jinja core. This doesn't match the general behavior of other
Undefined
types. If you think it would be generally useful to others, you can release it as an extension on PyPI, there's nothing required from Jinja itself for this.
Consider reopen this. I can tell you StrictUndefined
is a mistake. I have updated examples above.
This feature is done by introducing a new type of undefined class called
NeverUndefined
.The problem is that when using the previously most restricted undefined policy
StrictUndefined
is not enough.Take example on the following template:
NeverUndefined
will capture this error because in the normal case one shall pass three parameters to this macro in order to call it.StrictUndefined
will not.And this problem would be harder to debug, if one pass these undefined variables to another macro or function calls.
Take another example:
StrictUndefined
will not throw error. It will produce:However,
NeverUndefined
will:The implementation: