问题
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