是否有办法覆盖子模板中父模板内部和embed
标签内定义的块.eg:我有三个模板:a
,b
和{{1 }}。 c
嵌入a
和b
扩展c
。
a
{# a.html.twig #}
{% embed b.html.twig %}
{% block content %}
laksjflkj
{% block placeholder %}
I want to override this template in c, it is actually defined here and has nothing to do with b
{% endblock placeholder %}
{% endblock content %}
{% endembed %}
{# b.html.twig #}
{% block content %}
blahblah
{% endblock %}
如何覆盖{# c.html.twig #}
{% extends 'a.html.twig' %}
{% block placeholder %}
let's override the block defined inside a
{% endblock placeholder %}
内的placeholder
块?
答案 0 :(得分:1)
您必须创建一个名为d.html.twig
的新文件,该文件会扩展c.html.twig
并覆盖您的placeholder
块,如下所示:
{# d.html.twig #}
{% extends 'c.html.twig' %}
{% block placeholder %}
Overrided !
{% endblock placeholder %}