-
StackOverflow 文件
-
twig 教程
-
模板繼承
-
更改包含的模板的內容
article.twig.html
<article>
<h1>{{ article.title }}</h1>
{% block content %}
<p>{{ article.content }}</p>
{% endblock %}
</article>
articles.twig.html
{# use default template for article #}
{% for article in articles %}
{% include "article.twig.html" %}
{% endfor %}
{# use custom template for article #}
{% for article in articles %}
{% embed "article.twig.html" %}
{% block content %}
<img src="{{ article.image }}" alt="{{ article.title }}" />
{{ parent() }}
{% endblock %}
{% endembed %}
{% endfor %}