fabpot/Twig — Issue #644: Partials / Inherited blocks suggestion
Author: jhogendorn
Created: 2012-02-23 02:20:40+00:00
State: open

It would be good if I could include a template, and allow that template to extend upon blocks in the file doing the include. As far as I can make out, there's no real way to do this between import, use, and include.

ie:

{# parent.twig #}
{% block javascript %}
{% endblock %}

{# child.twig #}
{% extends 'parent.twig' %}
{% block javascript %}
{{ parent() }}
{% endblock %}
{% include subtemplate with subtemplatedata %}

{# subtemplate.twig #}
{% block javascript %}
{{ parent() }} {# ie, this code should appear in child.twigs javascript block #}
alert('some subtemplate specific javascript');
{% endblock %}