Twig extend template on condition

前端 未结 5 1022
刺人心
刺人心 2020-12-14 00:23

I use Symfony 2 with Twig and my question is pretty straightforward:

In a view I want to extend one of the layouts based on a variable. If the variable is fals

5条回答
  •  佛祖请我去吃肉
    2020-12-14 00:48

    You cannot extends multiple template, that's why you've got the error, if you want to so, you need to push them in an array like below.

    {% extends ['MyAppCustomBundle::Layout/layout.html.twig', 'FOSUserBundle::layout.html.twig'] %}

    But you will need to use Twig version 1.2 to do it. twig documentation

提交回复
热议问题