P
P
Peter2013-11-26 18:31:57
PHP
Peter, 2013-11-26 18:31:57

Silex + Twig. Why is it impossible to include a block in a template?

Hi
For the first time I tried to take out part of the layout in a separate file and include it in the template.
I develop on silex using twig.
Everything seems simple in the twig documentation:

{% include 'header.html' %}
    Body
{% include 'footer.html' %}

http://twig.sensiolabs.org/doc/tags/include.html
After pasting like this I got the following error:
Twig_Error_Loader: Template "header.html" is not defined () in "article_add.twig" at line 26.
What do you recommend?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Vinogradov, 2013-11-26
@Alcospb

header.html, footer.html are in the same directory?

D
Dmitry Sergeev, 2013-11-26
@JetMaster

show all the code that works with twig.
apparently, you are working with twig something like this
$loader = new Twig_Loader_String();
$twig = new Twig_Environment($loader);
if the templates are in files, then you need
$loader = new Twig_Loader_Filesystem('/path/to/templates');
$twig = new Twig_Environment($loader);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question