{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for category, message in messages %} {% set bootstrap_class = 'danger' if category == 'error' else category %} {% set bootstrap_class = 'warning' if category == 'warning' else bootstrap_class %} {% set bootstrap_class = 'success' if category == 'success' else bootstrap_class %} {% set bootstrap_class = 'info' if category == 'message' else bootstrap_class %} {% endfor %} {% endif %} {% endwith %}