{{ dump(extend) }}
结果:
boolean false
当我想做这个时:
{% if extend is true %}
{% extends 'WelcomePageBundle:Default:welcome_page.html.twig' %}
{% endif %}
它不起作用。为什么?
错误:
The test "false" does not exist in FOSUserBundle:ChangePassword:changePassword.html.twig at line 1
最佳答案
它必须是 {% if extend %}
— 因为 extend
已经是一个 bool 值——或者 {% if extend == true %}
. is
用于 tests ;不是为了比较。
关于symfony - bool 逻辑不像我在 Twig 中所期望的那样工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15088710/