- Issue created by @pdureau
- 🇫🇷France Grimreaper France 🇫🇷
Also in ui_suite_zurb_foundation: https://git.drupalcode.org/project/ui_suite_zurb_foundation/-/blob/1.0.x...
- 🇫🇷France pdureau Paris
This issue is already present in Drupal Core: https://git.drupalcode.org/project/drupal/-/blob/10.1.x/core/modules/lay...
{% set classes = [ 'layout', 'layout--' ~ layout.id|clean_class, ] %} {% if content %} <div{{ attributes.addClass(classes) }}> {% for region in layout.getRegionNames %} {% if content[region] %} <div {{ region_attributes[region].addClass('layout__region', 'layout__region--' ~ region|clean_class) }}> {{ content[region] }} </div> {% endif %} {% endfor %} </div> {% endif %}
But only for the default layout template, with "dynamic" regions.
The other templates don't loop on regions, they "statically print" each region in the Twig code, avoiding to use a PHP object and its method.
Example: https://git.drupalcode.org/project/drupal/-/blob/10.1.x/core/modules/lay...
<div{{ attributes.addClass(classes) }}> ... {% if content.first %} <div {{ region_attributes.first.addClass('layout__region', 'layout__region--first') }}> {{ content.first }} </div> {% endif %} {% if content.second %} <div {{ region_attributes.second.addClass('layout__region', 'layout__region--second') }}> {{ content.second }} </div> {% endif %} ... </div>
So, this may be the solution.
- 🇫🇷France Grimreaper France 🇫🇷
Hi,
Ok for this solution.
In this case this would mean that in the themes we would have 4 templates instead of one for the layout 1, 2, 3, 4 columns, maybe with some duplicated code snippet between the templates but that is ok.
Maybe it will also improve the readability for newcomers in those themes and not having the habits of layouts and Layout Options.
- Issue was unassigned.
- Status changed to Postponed
about 1 year ago 1:12pm 15 March 2024 - 🇫🇷France pdureau Paris
If we merge layout options into the upcoming UI Patterns 2.x module, we will not need to do that anymore.