在 Twig/Symfony2 中引用模板 [英] Referencing a template in Twig / Symfony2
本文介绍了在 Twig/Symfony2 中引用模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一个包中的一个 Twig 模板调用另一个包中的另一个 Twig 模板,但我无法引用它.
A Twig template in one bundle calls another Twig template in another bundle, but I can't reference it.
文件在此文件夹中:
src/Company/Bundle/ActivityBundle/Resources/views/Default/index.html.twig
我试图从另一个包中的 Twig 文件中引用它,如下所示:
And I am trying to reference it from a Twig file in another bundle like this:
{% extends "Company/Bundle/ActivityBundle/index.html.twig" %}
我已经尝试了所有可能的组合,但它就是无法实现,并且出现Twig_Error_Loader:无法找到模板"错误
I've tried every possible combination, but it just doesn't pick it up and I get a "Twig_Error_Loader: Unable to find template" error
推荐答案
我想你错过了模板路径的 Default
部分:
I think you've missed Default
part of template path:
{% extends "Company/Bundle/ActivityBundle/Default/index.html.twig" %}
或者我更喜欢:
{% extends "CompanyBundleActivityBundle:Default:index.html.twig" %}
希望这有帮助;)
这篇关于在 Twig/Symfony2 中引用模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文