4 * Default theme implementation for status messages.
6 * Displays status, error, and warning messages, grouped by type.
8 * An invisible heading identifies the messages for assistive technology.
9 * Sighted users see a colored box. See http://www.w3.org/TR/WCAG-TECHS/H69.html
12 * Add an ARIA label to the contentinfo area so that assistive technology
13 * user agents will better describe this landmark.
15 * Available variables:
16 * - message_list: List of messages to be displayed, grouped by type.
17 * - status_headings: List of all status types.
18 * - display: (optional) May have a value of 'status' or 'error' when only
19 * displaying messages of that specific type.
20 * - attributes: HTML attributes for the element, including:
21 * - class: HTML classes.
25 * @see template_preprocess_status_messages()
28 {# Save original attribute classes. This is needed to override in loop below. #}
29 {# @see https://www.drupal.org/project/bootstrap/issues/2892936 #}
30 {% set classes = attributes.offsetGet('class')|default({}) %}
32 set status_heading = {
33 'status': 'Status message'|t,
34 'error': 'Error message'|t,
35 'warning': 'Warning message'|t,
36 'info': 'Informative message'|t,
40 set status_classes = {
47 {% for type, messages in message_list %}
49 set message_classes = [
51 'alert-' ~ status_classes[type],
55 {# Reset the attribute classes and then add the message specific classes. #}
56 <div{{ attributes.setAttribute('class', classes).addClass(message_classes).setAttribute('role', 'alert') }}>
57 <button role="button" class="close" data-dismiss="alert" aria-label="{{ 'Close'|t }}"><span aria-hidden="true">×</span></button>
58 {% if status_headings[type] %}
59 <h4 class="sr-only">{{ status_headings[type] }}</h4>
61 {% if messages|length > 1 %}
62 <ul class="item-list item-list--messages">
63 {% for message in messages %}
64 <li class="item item--message">{{ message }}</li>