Skip to content
Myr

Keep flashed message examples in one place.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Ron DuPlain · committed by Ron DuPlain · parent 81010bf · Browse files · 2 files+13 added−35 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+13 added−35 removed

  • other:+13 added−35 removed

2 files+13 added−35 removed

modified:docs/patterns/flashing.rst+12 added-11 removed
127 unmodified lines
128render each category in a separate block.129130.. sourcecode:: html+jinja131132{% with errors = get_flashed_messages(category_filter=["error"]) %}133 {% if errors %}134 <div class="errors">135 <ul>136 {% for message in messages %}137 <li class="error">{{ message }}</li>138 {% endfor %}139 </ul>140 </div>141 {% endif %}142{% endwith %}132 {% with errors = get_flashed_messages(category_filter=["error"]) %}133 {% if errors %}134 <div class="alert-message block-message error">135 <a class="close" href="#">×</a>136 <ul>137 {%- for msg in errors %}138 <li>{{ msg }}</li>139 {% endfor -%}140 </ul>141 </div>142 {% endif %}143 {% endwith %}
modified:flask/helpers.py+1 added-24 removed
279 unmodified lines
280 text (`True` gives a tuple, where `False` gives just the message text).281 * `category_filter` filters the messages down to only those matching the282 provided categories.283284 Example usage:284 See :ref:`message-flashing-pattern` for examples.285286 .. sourcecode:: html+jinja287288 {% for category, msg in get_flashed_messages(with_categories=true) %}289 <p class=flash-{{ category }}>{{ msg }}290 {% endfor %}291292 Example usage similar to http://twitter.github.com/bootstrap/#alerts:293294 .. sourcecode:: html+jinja295296 {% with errors = get_flashed_messages(category_filter=["error"]) %}297 {% if errors %}298 <div class="alert-message block-message error">299 <a class="close" href="#">×</a>300 <ul>301 {%- for msg in errors %}302 <li>{{ msg }}</li>303 {% endfor -%}304 </ul>305 </div>306 {% endif %}307 {% endwith %}308286 .. versionchanged:: 0.3287 `with_categories` parameter added.288289 .. versionchanged:: 0.9
399 unmodified lines