是否有一种更优雅的方法来检查 Twig 中的变量是否既已定义(可以安全引用/使用)又检查布尔值,就像我在下面所做的那样?
我有许多 Twig 模板,其中的逻辑很混乱,我希望它更具可读性,但是我不知道在 Twig 中这是如何完成的。
{% if primaryMethod is defined and paymentInProgress is defined and transactions is defined and not primaryMethod and not paymentInProgress and not transactions %}