{% block appendable %}
{# Assuming your sub1 template is in AcmeDemoBundle/Resources/views/MySub/sub1.html.twig #}
{% include "AcmeDemoBundle:MySub:sub1.html.twig" %}
{% endblock appendable %}
Using Inheritance:
If you wish, you can use the {{ parent() }} keyword to use inheritance. For example, if you want to include sub1.html.twig by default but append sub2.html.twig in your child template, you can do the following:
base.html.twig
{% block content %}
{% include "AcmeDemoBundle:MySub:sub1.html.twig" %}
{% endblock %}
site.html.twig
{% extends base.html.twig %}
{% block content %}
{# render what happens in the parent content block #}
{{ parent() }}
{# and append sub2.html.twig as well #}
{% include "AcmeDemoBundle:MySub:sub2.html.twig" %}
{% endblock content %}
Reference:
http://stackoverflow.com/questions/14564351/append-content-to-block-from-multiple-subtemplates
No comments:
Post a Comment