Description
Hi,
Actually in symfony, when you want to override a template from a bundle, you have to override this template into your app/Resources/OverridenBundle. But you actually have to copy/paste this template.
If you try to extend it, you will fall into an infinite loop, as the loader will try to load the overriden template, which try to load the overriden template, etc.
Of course if your bundle has some "extension point" (in fact, like sonata, you can have in your bundle a template "myfeature_full.html.twig" and a template "myfeature.html.twig" which just extends the full template, allowing overriden templates to uses blocks and so) you can use it. But it needs more template and the bundle you want to override must allow this.
Actually there is no technical way to bypass this behaviour and a little convention can do the trick.
Let's imagine the convention is to add the "!" mark at the beginning of the name of the template when you want to extends it, you'll be able to do that kind of thing:
src/vendor/ccmbenchmark/mybundle/src/Resources/views/base.html.twig
{% block title %}<h1>Hello</h1>{% endblock %}
{% block content %}
{# big content with some logic i don't want to copy/paste #}
{% endblock %}
app/Resources/MyBundle/views/base.html.twig
{% extends '!MyBundle::base.html.twig' %}
{% block title %}<h2>Hi !</h2>{% endblock %}
The "!" basically say's "Hey, let's drop off all override. I just want this template from this bundle".
What do you think about this feature? Actually that would be very useful in a lot of cases and will just help to empower bundles !
If this was accepted, I would agree to dev this feature.
/cc @dunglas