I've looked thoroughly over Symfony related questions on this site but can't find the answer I need.
我在这个网站上彻底查看了Symfony相关问题,但找不到我需要的答案。
I'm using Symfony 2.0.9 with PHP 5.3.6 and my file structure looks like this:
我正在使用Symfony 2.0.9和PHP 5.3.6,我的文件结构如下所示:
src/
Blog/
TestBundle/
Resources/
views/
Default/
index.html.twig
header.html.twig
Inside of index.html.twig I have:
在index.html.twig里面我有:
<div id="header">
{% include "BlogTestBundle:Resources:Default:header.html.twig" %}
</div>
It keeps erroring out with
它不断出错
Twig_error_loader: Unable to find template
Twig_error_loader:无法找到模板
no matter what I use for the path. Why isn't it finding the file? They're even in the same directory!
无论我用什么路径。为什么不找到文件?他们甚至在同一个目录中!
Anyone have any idea what I'm doing wrong?
任何人都知道我做错了什么?
1 个解决方案
#1
18
twig file includes should follow the format below:
twig文件包括应遵循以下格式:
FullBundleName:ControllerName:filename
You can also amend parts if they're not present, i.e. for just a file under a bundle /views directory you can use FullBundleName::filename
如果它们不存在,你也可以修改它们,即只有bundle / views目录下的文件你可以使用FullBundleName :: filename
So in your case, use BlogTestBundle:Default:header.html.twig
所以在你的情况下,使用BlogTestBundle:默认:header.html.twig
#1
18
twig file includes should follow the format below:
twig文件包括应遵循以下格式:
FullBundleName:ControllerName:filename
You can also amend parts if they're not present, i.e. for just a file under a bundle /views directory you can use FullBundleName::filename
如果它们不存在,你也可以修改它们,即只有bundle / views目录下的文件你可以使用FullBundleName :: filename
So in your case, use BlogTestBundle:Default:header.html.twig
所以在你的情况下,使用BlogTestBundle:默认:header.html.twig