2
我無法在下面的代碼中工作的唯一原因是我希望它使用位於調用軟件包的文件夾中的navigation.html.twig文件它。因此,在這個例子中,它是bundle 2.那麼是否有可能不對其中的bundle路徑進行硬編碼?很明顯,我沒有在代碼中對路徑進行硬編碼,但它不能像這樣工作(其他所有工作,只是參考navigation.html.twig文件)。在Symfony2中的兩個軟件包之間引用Twig模板
捆綁1保持主父HTML /枝條並調用位於哪個束的navigation.html.twig文件調用本文件:
<! inside bundle 1 -->
<!DOCTYPE html>
<head>
<head>
<html>
<body>
<div id="navigation">
{% include 'navigation.html.twig' %}
</div>
<div id="content">
{% block the_content %}
{% endblock %}
</div>
</body>
</html>
束2個呼叫捆綁1:
{# inside bundle 2 #}
{% extends "Bundle1:index.html.twig" %}
{% block content %}
This is the content for this page
{% endblock %}