Referencing a template in Twig / Symfony2

删除回忆录丶 提交于 2021-01-28 00:40:18

问题


A Twig template in one bundle calls another Twig template in another bundle, but I can't reference it.

The file is in this folder:

src/Company/Bundle/ActivityBundle/Resources/views/Default/index.html.twig

And I am trying to reference it from a Twig file in another bundle like this:

{% extends "Company/Bundle/ActivityBundle/index.html.twig" %}

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


回答1:


I think you've missed Default part of template path:

{% extends "Company/Bundle/ActivityBundle/Default/index.html.twig" %}

or as I prefer much more:

{% extends "CompanyBundleActivityBundle:Default:index.html.twig" %}

Hope this helps ;)



来源:https://stackoverflow.com/questions/15528270/referencing-a-template-in-twig-symfony2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!