{% with messages = get_flashed_messages(with_categories=True) %}
    {% if messages %}
        {% for category, message in messages %}
            {% if category == 'error' %}
                {% set icon = 'glyphicon glyphicon-exclamation-sign' %}
            {% elif category == 'success' %}
                {% set icon = 'glyphicon glyphicon-ok-sign' %}
            {% else %}
                {% set icon = 'glyphicon glyphicon-info-sign' %}
            {% endif %}
            <div class="alert alert-{{ category }}">
                <span class="{{ icon }}"></span>&nbsp;
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                {{ message }}
            </div>
        {% endfor %}
    {% endif %}
{% endwith %}
