{%- macro alert_type(val) %}
{%- if val == 'error' -%}alert-danger{% endif %}
{%- if val == 'warning' -%}alert-warning{% endif %}
{%- if val == 'info' -%}alert-info{% endif %}
{%- if val == 'success' -%}alert-success{% endif %}
{% endmacro -%}

{%- macro flash_messages() %}
    {% with messages = get_flashed_messages(with_categories=True) %}
        {% if messages %}
            {% for category, message in messages %}
                <div class="alert {{ alert_type(category) }}">
                    <p class="flash">{{ 'Error: ' if category == 'error' else '' }}{{ message }}</p>
                </div>
            {% endfor %}
        {% endif %}
    {% endwith %}
{% endmacro -%}

{%- macro alert_type(val) %}
{% set types = ['error', 'warning', 'info', 'success'] %}
{%- if val == 'error' -%}alert-danger{% endif %}
{%- if val == 'warning' -%}alert-warning{% endif %}
{%- if val == 'info' -%}alert-info{% endif %}
{%- if val == 'success' -%}alert-success{% endif %}
{%- if val not in types -%}alert-info{% endif %}
{% endmacro -%}

{%- macro flash_messages() %}
    {% with messages = get_flashed_messages(with_categories=True) %}
        {% if messages %}
            {% for category, message in messages %}
                <div class="alert {{ alert_type(category) }}">
                    <p class="flash">{{ 'Error: ' if category == 'error' else '' }}{{ message }}</p>
                </div>
            {% endfor %}
        {% endif %}
    {% endwith %}
{% endmacro -%}

Set a default alert type for messages macro.
Set a default alert type for messages macro.
