List all Twig templates used in the current request

I'm using Symfony2 with Twig templating engine.

Is there any way to output a list of all Twig templates files loaded in the current request, including the ones loaded through extends , include , etc.?

That would make my life much easier when overriding third-party bundles' blocks, but I can't find a way to do it.


I've been looking for such a tool for a long time but never found it... The debug options of twig are very limited, and there is no tool in the sf2 dev bar dedicated to it...

I always add twig or html comments on top of each of my templates to get an idea of where I am and why during development or on the final page.


You can try this code, it puts filenames in HTML like this:

<!-- START templatename.html.twig -->
...
<!-- END templatename.html.twig -->

I know, that it is not a good solution, but it is better than nothing.


not a problem when you are working in dev in app_dev.php

expand bottom SF toolbar, click on 200 status or on @your_rote_name you will redirect to smt like localhost/_profiler/s0meha5h?panel=* then click on left menu on TWIG then url will be like localhost/_profiler/s0meha5h?panel=twig

and you will see all templates like FolderYourBundle:Folder:twig_file_name.html.twig that loads one by one!

链接地址: http://www.djcxy.com/p/18566.html

上一篇: 我们如何在Android中动态更改Android应用程序图标

下一篇: 列出当前请求中使用的所有Twig模板