{# LIBRARIES #}
{{ attach_library('ui_patterns/libraries.bs_alert') }}
{{ attach_library('ui_patterns/alerts.alerts_lib') }}

{# VARIABLES #}
{% set status_heading = {
  'status': 'Status'|t,
  'error': 'Error'|t,
  'warning': 'Warning'|t,
  'info': 'Information'|t,
} %}
{% set status_mapping = {
  'status': 'success',
  'error': 'danger',
  'warning': 'warning',
  'info': 'info',
} %}
{% set messages_attributes = attributes %}

{# TEMPLATE #}
{% for type, messages in message_list %}

  {% embed '@molecules/tm-message/alert/alert.twig' with {
    'status': status_mapping[type],
    'header': status_heading[type],
    'messages': messages
  } only %}

  {% block content %}
    {% if messages|length > 1 %}
      <ul>
      {% for message in messages %}
        <li>{{- message -}}</li>
      {% endfor %}
      </ul>
    {% else %}
      <ul class="uln">
        <li class="lin">{{- messages|first -}}</li>
      </ul>
    {% endif %}
  {% endblock content %}

  {% endembed %}

{% endfor %}
