Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find the path to an include in Symfony2?

I've looked thoroughly over Symfony related questions on this site but can't find the answer I need.

I'm using Symfony 2.0.9 with PHP 5.3.6 and my file structure looks like this:

src/
  Blog/
    TestBundle/
      Resources/
        views/
          Default/
            index.html.twig
            header.html.twig

Inside of index.html.twig I have:

<div id="header">
{% include "BlogTestBundle:Resources:Default:header.html.twig" %}
</div>

It keeps erroring out with

Twig_error_loader: Unable to find template

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?

like image 829
varker Avatar asked Jan 18 '12 07:01

varker


1 Answers

twig file includes should follow the format below:

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

So in your case, use BlogTestBundle:Default:header.html.twig

like image 156
Inoryy Avatar answered Sep 21 '22 19:09

Inoryy