我正在尝试覆盖包含的块。
{# index.twig #}
{% extends "default.twig" %}
{% block content %}
html page content
{% endblock %}
{% block js %}
javascript
{% endblock %}
{# default.twig #}
{% include "header.twig" %}
{% block content %}
{% endblock %}
{% embed "/layouts/resources/footer.twig" %}
{% block footer %}
{% block js %}
{% endblock %}
{% endblock %}
{% endembed %}
{# footer.twig #}
{% block footer %}
{% endblock %}
我也试过嵌入,但也没有工作。
--Creating sequences here
--Pk sequence for characters table here
CREATE OR REPLACE SEQUENCE characters_pk_sequence MINVALUE 1 START WITH 1 INCREMENT BY 1;
-- End of PK sequence for characters table here
我读到这可以通过' include with'来完成。但我也无法做到这一点。
答案 0 :(得分:6)
这只适用于一招。你必须将“块”作为变量移交。
我删除了您的示例的一些行,以便更容易阅读:
index.twig
{% extends "default.twig" %}
{% block content %}
html page content
{% endblock %}
{% block footer %}
javascript
{% endblock %}
default.twig
{% block content %}
{% endblock %}
{% include "/layouts/resources/footer.twig" with {footer: block('footer')} %}
footer.twig
{% if footer is not empty %}
{{ footer|raw }}
{% endif %}