Browse Source

Keep flashed message examples in one place.

pull/341/merge
Ron DuPlain 13 years ago
parent
commit
c93ea5551c
  1. 23
      docs/patterns/flashing.rst
  2. 25
      flask/helpers.py

23
docs/patterns/flashing.rst

@ -129,14 +129,15 @@ render each category in a separate block.
.. sourcecode:: html+jinja
{% with errors = get_flashed_messages(category_filter=["error"]) %}
{% if errors %}
<div class="errors">
<ul>
{% for message in messages %}
<li class="error">{{ message }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% endwith %}
{% with errors = get_flashed_messages(category_filter=["error"]) %}
{% if errors %}
<div class="alert-message block-message error">
<a class="close" href="#">×</a>
<ul>
{%- for msg in errors %}
<li>{{ msg }}</li>
{% endfor -%}
</ul>
</div>
{% endif %}
{% endwith %}

25
flask/helpers.py

@ -281,30 +281,7 @@ def get_flashed_messages(with_categories=False, category_filter=[]):
* `category_filter` filters the messages down to only those matching the
provided categories.
Example usage:
.. sourcecode:: html+jinja
{% for category, msg in get_flashed_messages(with_categories=true) %}
<p class=flash-{{ category }}>{{ msg }}
{% endfor %}
Example usage similar to http://twitter.github.com/bootstrap/#alerts:
.. sourcecode:: html+jinja
{% with errors = get_flashed_messages(category_filter=["error"]) %}
{% if errors %}
<div class="alert-message block-message error">
<a class="close" href="#">×</a>
<ul>
{%- for msg in errors %}
<li>{{ msg }}</li>
{% endfor -%}
</ul>
</div>
{% endif %}
{% endwith %}
See :ref:`message-flashing-pattern` for examples.
.. versionchanged:: 0.3
`with_categories` parameter added.

Loading…
Cancel
Save