Skip to content

Instantly share code, notes, and snippets.

@stevepiercy
Created September 27, 2018 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevepiercy/1fc5ead166048f616b3a51d80cf86c68 to your computer and use it in GitHub Desktop.
Save stevepiercy/1fc5ead166048f616b3a51d80cf86c68 to your computer and use it in GitHub Desktop.
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