-
Notifications
You must be signed in to change notification settings - Fork 275
Open
Milestone
Description
I am using twig.js with strict_variables set to true.
If I have a template like this:
{% if pagination|default and pagination.links|default %}
...
{% endif %}
and I loaded it with a completely empty context, I would expect no errors. This works in PHP Twig and what is recommended.
In twig.js, I get a TwigException:
Can't access a key links on an null or undefined object.
It looks to me that twig.js is evaluating the truthiness of both operands even if the first one is false. I would not expect this, not only for this use case, but because JavaScript doesn't work this way either.
The workaround is this:
{% if pagination|default %}
{% if pagination.links|default %}
...
{% endif %}
{% endif %}
That makes the template harder to read and creates more indenting and whitespace then normal.