Skip to content

Override blocks defined in a template embedded by the base template? #3665

Description

base.html.twig

{% block css %}
{% endblock %}

{% block html %}
{% endblock %}

base.email.html.twig

{% extends 'base.html.twig' %}

{% block css %}
    <style>body { font-size: 11pt; }</style>
{% endblock %}
{% block html %}
    {% if true %}
        {% embed 'confirmation.html.twig' %}
        {% endembed %}

        {% block baseoverride %}
            BASE
        {% endblock %}
    {% endif %}
{% endblock %}

confirmation.html.twig

{% block suboverride %}
    SUBCONFIRM
{% endblock %}

reconfirmation.html.twig

{% extends 'base.email.html.twig' %}

{% block suboverride %}
    OVERRIDECONFIRM
{% endblock %}
{% block baseoverride %}
    SUB
{% endblock %}

The output is:

<style>body { font-size: 11pt; }</style>
CONFIRM
SUB

The baseoverride block defined in the template extended from is overridden, but the suboverride block in the template embedded by the base template is not. How would I go about overriding that block?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions