{{ dump(extend) }}
Result:
boolean false
And when I want to make this:
{% if extend is true %}
{% extends 'WelcomePageBundle:Default:welcome_page.html.twig' %}
{% endif %}
It doesn't work. Why?
Error:
The test "false" does not exist in FOSUserBundle:ChangePassword:changePassword.html.twig at line 1
It has to be either {% if extend %}
— because extend
is already a boolean — or {% if extend == true %}
. is
is used for tests; not for comparison.
You need to use empty
test:
Test empty checks if a variable is empty (null, false, empty array, or empty string).
{% if extend is not empty %}
...
{% endif %}
Take a look at the list of available tests as well as logic operators from the official Twig documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With