How to split region block render?
Question
Is it possible to split the rendering of the blocks in a region ? I have see this question Drupal 8 - How to split display the blocks separately in region.html.twig attempting to solve this by using {{ elements.search}}
and I have tried it, but no success yet.
I also tried {{ elements.children[0] }}
but this failed as well.
Is there a possible way of getting the array element out individually.
Many thanks
Solution
You can iterate through the blocks in this way:
{% for block_key, block in elements if block_key|first != '#' %}
<b>{{ block_key }}: </b>
{{ block }}
{% endfor %}
If you just need to know the blocks that are present in a given region, you could use this:
{{ dump(elements|keys) }}
Then you can print each block as:
{{ elements.key }}
Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange