{% set htmlAttr = '' %}
{% if attr is defined and attr is iterable %}
    {% for a, v in attr %}
        {% set htmlAttr = ' ' ~ htmlAttr ~ a ~ '=' ~ v %}
    {% endfor %}
{% endif %}

{% set htmlClass = 'btn ' ~ class ?? '' %}

{% if 'button' == type %}
    <button class="{{ htmlClass }}{% if icon is defined %} has-icon{% endif %}" type="submit"{{ htmlAttr }}>
        {% if text is defined %}<span>{{ text }}</span>{% endif %}

        {#% if icon is defined %}
            {{ include('Front/_component/icon.html.twig', icon) }}
        {% endif %#}
    </button>
{% elseif 'link' == type %}
    <a class="{{ htmlClass }}{% if icon is defined %} has-icon{% endif %}" href="{{ url ?? '#' }}"{{ htmlAttr }}>
        {% if text is defined %}<span>{{ text }}</span>{% endif %}

        {#% if icon is defined %}
            {{ include('Front/_component/icon.html.twig', icon) }}
        {% endif %#}
    </a>
{% endif %}
