Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The simplest case for #953034: [meta] Themes improperly check renderable arrays when determining visibility is a region that just consists of [#cache] but no renderable children.
In that case the region MUST be rendered, so even if in a twig template we did:
{% if (element_is_empty(content.sidebar_left)) %}
<div class="sidebar-left">
{{ content.sidebar_left }}
</div>
{% endif %}
in fact it would _need_ to be:
{% if (element_is_empty(content.sidebar_left)) %}
<div class="sidebar-left">
{{ content.sidebar_left }}
</div>
{% else %}
{{ content.sidebar_left }}
{% endif %}
which is very un-intuitive OR element_is_empty would need to actually render the content, which is less than ideal due to performance reasons as we would need to render the sidebar always twice.
Proposed resolution
In BlockPageVariant render empty regions.
Remaining tasks
- Discuss
Comments
Comment #2
Fabianx CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commentedThis was already fixed in a different way by ensuring that the cacheability metadata from the build is added to the top-level.
So this simple case is already fixed.