KubiRoazhon
KubiRoazhon

Reputation: 1839

How to pass data to an extended twig template

I've a twig template named (header.html.twig) that i call in every template:{% include "Bundle:Tempalte:header.html.twig" %}. I want to passe some data to this template without using the render method of symfony. Here's the structure of the template calling.

The controller :

$this->render('index.html.twg',array());

The Index twig template index.html.twg :

{% include "Bundle:Tempalte:header.html.twig" %}`
    {% block code %}
       //some html code
    {% endblock %}

So there's any solutions please.

Upvotes: 0

Views: 1422

Answers (1)

Kvn91
Kvn91

Reputation: 179

{% include "Bundle:Template:header.html.twig" with {'foo': 'bar'} %}

Read the documentation : http://twig.sensiolabs.org/doc/tags/include.html

Upvotes: 1

Related Questions