{% extends 'coderedcms/blocks/base_block.html' %}
{% load wagtailcore_tags coderedcms_tags %}
{% block block_render %}
{% with a_id=self.accordion.id accordion=self.accordion %}
<div class="accordion" id="accordion-{{a_id}}">
  {% for panel in accordion.accordion_panels.all %}
  <div id="{{panel.custom_id}}" class="accordion-item {{panel.custom_css_class}}">
    <h2 class="accordion-header" id="accordion-heading-{{forloop.counter}}">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
        data-bs-target="#collapse-{{a_id}}-{{forloop.counter}}" aria-expanded="false"
        aria-controls="collapse-{{a_id}}-{{forloop.counter}}">
        {{panel.name}}
      </button>
    </h2>
    <div id="collapse-{{a_id}}-{{forloop.counter}}" class="aaccordion-collapse collapse"
      aria-labelledby="accordion-heading-{{forloop.counter}}" data-bs-parent="#accordion-{{a_id}}">
      <div class="accordion-body">
        {% for block in panel.content %}
        {% include_block block %}
        {% endfor %}
      </div>
    </div>
  </div>
  {% endfor %}
</div>
{% endwith %}
{% endblock %}
