Extended templates cannot overwrite inherited blocks if they are added via inlcude
Consider three templates:
Base.html
<h1>Base</h1> {% block sectionA %}[base sectionA]{% endblock %} {% include 'Included' %}
Included.html
<h2>Included</h2> {% block sectionB %}[included sectionB]{% endblock %}
Extended.html
{% extends 'Base' %} {% block sectionA %}({{ parent() }})=>[extended sectionA]{% endblock %} {% block sectionB %}({{ parent() }})=>[extended sectionB]{% endblock %}
If Extended.html is used for output, it generates the following:
Base ([base sectionA])=>[extended sectionA] Included [included sectionB]
I would assume both blocks should be replaced with extended blocks, but the block defined in the included template is not being replaced.
It looks like Twig uses a separate keyword to accomplish this, http://twig.sensiolabs.org/doc/tags/use.html, and they have very strict criteria that must be met by the template being included.
It's seems like a nice feature that probably requires more thought, discussion, and work than I'm able to put in at this time. I'm willing to review a pull request but I suspect that because Twig used a separate keyword, whoever implements this will find that this is more complicated than it first appears.
Isn't it possible to process the include first and rather than parsing, just pasting it's content into the template intermediately and finally evaluate the resulting template? I am not aware of the implementation, thus I suspect it is as you said - more complicated than it first appears.