是否可以创建多个继承的扩展链,如下所示:
archive-events.twig extends archive.twig
archive.twig 扩展 base.twig
或者扩展链是否也被视为多重继承?
也可以覆盖子块,如下所示:
archive.twig
--block content
----块元
归档-events.twig
----块元
...
这是archive-events.twig:
{# archive-events.twig #}
{% extends "archive.twig" %}
{% block content %}
{{ parent() }}
{% block articles %}
{% for post in posts %}
{% include "article-event.twig" %}
{% endfor %}
{% endblock %}
{% endblock %}
archive.twig:
{# archive.twig #}
{% extends "base.twig" %}
{% block content %}
<!-- start:article-archive -->
<section class="section layout context--post-list context--event">
<div class="wrapper">
<div class="container">
<header>
{% block header %}
<h1 class="title">{{ title }}</h1>
{% endblock %}
</header>
<div class="filter">
{% block archive_filter %}
{% endblock %}
</div>
<div class="articles">
{% block articles %}
{% endblock %}
</div><!-- .articles -->
</div><!-- .container -->
</div><!-- .wrapper -->
</section>
<!-- end:article-archive -->
{% endblock %}
答案 0 :(得分:1)