Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Examine all flash message queues, pop them, and display their messages with the correct Twitter Bootstrap alert
{% macro render_flash(key, cls) %}
{% if request.session.peek_flash(key) %}
{% for msg in request.session.pop_flash(key) %}
<div class="alert alert-{{ cls }} alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
{{ msg }}
</div>
{% endfor %}
{% endif %}
{% endmacro %}
{{ render_flash('', 'info') }}
{{ render_flash('info', 'info') }}
{{ render_flash('success', 'success') }}
{{ render_flash('warning', 'warning') }}
{{ render_flash('error', 'danger') }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment