列出当前请求中使用的所有 Twig 模板 [英] List all Twig templates used in the current request
本文介绍了列出当前请求中使用的所有 Twig 模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将 Symfony2 与 Twig 模板引擎一起使用.
有没有办法输出当前请求中加载的所有Twig模板文件的列表,包括通过extends
、include
等加载的文件?>
当覆盖第三方包的块时,这会让我的生活更轻松,但我找不到办法做到这一点.
解决方案
你可以试试这段代码,它将文件名放在 HTML 中,如下所示:
...<!-- END templatename.html.twig -->
我知道,这不是一个好的解决方案,但总比没有好.
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.
解决方案
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.
这篇关于列出当前请求中使用的所有 Twig 模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文