forked from orbit-oss/flask
Keep flashed message examples in one place.
This commit is contained in:
parent
81010bf7af
commit
c93ea5551c
2 changed files with 13 additions and 35 deletions
|
|
@ -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 %}
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue