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
|
.. sourcecode:: html+jinja
|
||||||
|
|
||||||
{% with errors = get_flashed_messages(category_filter=["error"]) %}
|
{% with errors = get_flashed_messages(category_filter=["error"]) %}
|
||||||
{% if errors %}
|
{% if errors %}
|
||||||
<div class="errors">
|
<div class="alert-message block-message error">
|
||||||
<ul>
|
<a class="close" href="#">×</a>
|
||||||
{% for message in messages %}
|
<ul>
|
||||||
<li class="error">{{ message }}</li>
|
{%- for msg in errors %}
|
||||||
{% endfor %}
|
<li>{{ msg }}</li>
|
||||||
</ul>
|
{% endfor -%}
|
||||||
</div>
|
</ul>
|
||||||
{% endif %}
|
</div>
|
||||||
{% endwith %}
|
{% 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
|
* `category_filter` filters the messages down to only those matching the
|
||||||
provided categories.
|
provided categories.
|
||||||
|
|
||||||
Example usage:
|
See :ref:`message-flashing-pattern` for examples.
|
||||||
|
|
||||||
.. 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 %}
|
|
||||||
|
|
||||||
.. versionchanged:: 0.3
|
.. versionchanged:: 0.3
|
||||||
`with_categories` parameter added.
|
`with_categories` parameter added.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue