fabpot/Twig — Issue #541: Conditional inheritance
Author: dinamic
Created: 2011-12-01 08:14:51+00:00
State: open

For a number of cases we would need to override one or another block. For example, we have a controller which executes in both standalone and in ajax mode. While requested via ajax we would not want to show the navigation.

At first I tried to use the following structure:

> {% if isEmbed %}
> {% block navigation "" %}
> {% endif %}

Unfortunately, this would override the navigation block no matter the value of the isEmbed variable.

To workaround this I've used:

> {% block navigation %}
> {% if isEmbed != true %}
> {{ parent() }}
> {% endif %}
> {% endblock navigation %}