我正在开发使用Symfony2和 Twig 的模板的应用程序。我正在为模板使用3级结构。 Base.html.twig,layout.html.twig和childtemplate.html.twig。
问题是我试图通过使用include在下一个子模板中包含一个example.html(公共(public)html文件),但是它无法正常工作。问题出在哪里?
{# 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 %}
最佳答案
取决于它的位置。假设它在Anotatzailea/AnotatzaileaBundle/Resources/views/example.html.twig
中;那么您可以像这样包含它:
{% include 'AnotatzaileaAnotatzaileaBundle::example.html.twig' %}