{%- with messages = get_flashed_messages(with_categories=true),
        cat_map = {'error': 'danger', 'message': 'info'} %}
  {%- if messages %}
    {%- for cat, message in messages %}
      <div class="alert alert-block alert-dismissable alert-{{ cat_map.get(cat, cat) }}">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
        {{ message }}
      </div>
    {%- endfor %}
  {%- endif %}
{%- endwith %}
