
<?php $accordionItems = $block->elements()->toBlocks(); ?>
<div class="accordion-section">
  <?php if ($accordionItems->isNotEmpty()) : ?>
    <<?= $level = $block->level()->or('h2') ?>><?= $block->heading() ?></<?= $level = $block->level()->or('h2') ?>>
    <?php foreach ($accordionItems as $key=>$accordionItem) : ?>
      <?php snippet('blocks/' . $accordionItem->type(), [
        'block' => $accordionItem,
        'index' => $accordionItem->indexOf(),
        'as_group' => $block->group()->toBool(),
        'parentid' => $block->id()
      ]) ?>
    <?php endforeach ?>
  <?php endif; ?>
</div>