{% for account_type, accounts in type_accounts|items %} {# Use a scoped variable so that the accounts generator can be reused #} {% with accounts = accounts|list %}

{{ account_type.type_name }} {% if accounts|length> 1 %} ${{ accounts|sum(attribute='balance')|currency }} {% endif %}

{% endwith %} {% endfor %}