相关疑难解决方法(0)

附加内容以阻止多个子模板

关于如何用树枝附加块有几个问题.答案总是使用继承和使用,然后调用parent().不知怎的,我不知道这在我的具体情况下是如何工作的:

base.html.twig

{% block content %}{% endblock %}
{% block appendable %}
{% endblock %}
{% block another_appendable %}
{% endblock %}
Run Code Online (Sandbox Code Playgroud)

site.html.twig

{% extends base.html.twig %}
{% block content %}
{# Here use/include/embed, i dont know #}
{% use sub1.html.twig %}
{% use sub2.html.twig %}
{% endblock content %}
Run Code Online (Sandbox Code Playgroud)

sub1.html.twig

Some content that should be directly rendered
{% block appendable %}
some stuff that should be added to appendable
{% endblock %}
{% block another_appendable %}
This content should …
Run Code Online (Sandbox Code Playgroud)

symfony twig

2
推荐指数
1
解决办法
5524
查看次数

标签 统计

symfony ×1

twig ×1