Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 Include in html in Twig

Tags:

html

twig

symfony

I am developing an application using Symfony2 and twig for templates. I am using a 3 level structure for templates. Base.html.twig, layout.html.twig and childtemplate.html.twig. The problem is I am trying to include one example.html (common html file) in the next child template by using include but it doesnt work properly. Where can the problem be?

{# src/Anotatzailea/AnotatzaileaBundle/Resources/views/Page/testuaanotatu.html.twig #}
{% extends 'AnotatzaileaAnotatzaileaBundle::layout.html.twig' %}

{% block title %}Testua anotatu{% endblock%}

{% block body %}
    {% include "var/www/Symfony/web/example.html" %}
{% endblock %}
like image 427
Haritz Avatar asked Mar 22 '12 17:03

Haritz


1 Answers

Depends on where it's located. Let's say it's in Anotatzailea/AnotatzaileaBundle/Resources/views/example.html.twig; then you would include it like this:

{% include 'AnotatzaileaAnotatzaileaBundle::example.html.twig' %}
like image 194
Elnur Abdurrakhimov Avatar answered Oct 13 '22 05:10

Elnur Abdurrakhimov