How to var_dump variables in twig templates?

后端 未结 14 1483
滥情空心
滥情空心 2020-12-22 17:43

View layer pattern where you only present what you have been given is fine and all, but how do you know what is available? Is there a \"list all defined variables\" function

14条回答
  •  死守一世寂寞
    2020-12-22 18:07

    As of Twig 1.5, the correct answer is to use the dump function. It is fully documented in the Twig documentation. Here is the documentation to enable this inside Symfony2.

    {{ dump(user) }}
    

提交回复
热议问题