{% macro govukAccordion(params) %} {% from "govuk_frontend_jinja/macros/attributes.html" import govukAttributes %} {% from "govuk_frontend_jinja/macros/i18n.html" import govukI18nAttributes %} {%- macro _accordionItem(params, item, index) %} {%- set headingLevel = params.headingLevel if params.headingLevel else 2 %}
{{ item.heading.html | safe | trim | indent(8) if item.heading.html else item.heading.text }} {% if item.summary and (item.summary.html or item.summary.text) %}
{{ item.summary.html | safe | trim | indent(8) if item.summary.html else item.summary.text }}
{% endif %}
{% if item.content.html %} {{ item.content.html | safe | trim | indent(6) }} {% elif item.content.text %}

{{ item.content.text | trim | indent(8) }}

{% endif %}
{% endmacro -%}
{% for item in params['items'] %} {% if item %}{{ _accordionItem(params, item, loop.index) }}{% endif %} {% endfor %}
{% endmacro %}