Skip to content
Myr

Add get_flashed_messages to CHANGES, expand docs.

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 fa069f9 · Browse files · 2 files+32 added−3 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+32 added−3 removed

  • other:+32 added−3 removed

2 files+32 added−3 removed

modified:flask/helpers.py+29 added-2 removed
249 unmodified lines
250 """Flashes a message to the next request. In order to remove the251 flashed message from the session and to display it to the user,252 the template has to call :func:`get_flashed_messages`.253254 .. versionchanged: 0.3254 .. versionchanged:: 0.3255 `category` parameter added.256257 :param message: the message to be flashed.258 :param category: the category for the message. The following values
11 unmodified lines
270 the same messages. By default just the messages are returned,271 but when `with_categories` is set to `True`, the return value will272 be a list of tuples in the form ``(category, message)`` instead.273274 Filter the flashed messages to one or more categories by providing those275 categories in `category_filter`. This allows rendering categories in276 separate html blocks. The `with_categories` and `category_filter`277 arguments are distinct:278279 * `with_categories` controls whether categories are returned with message280 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: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 %}308309 .. versionchanged:: 0.3310 `with_categories` parameter added.311285 .. versionchanged: 0.9312 .. versionchanged:: 0.9313 `category_filter` parameter added.314315 :param with_categories: set to `True` to also receive categories.316 :param category_filter: whitelist of categories to limit return values
395 unmodified lines
modified:CHANGES+3 added-1 removed
32 unmodified lines
33- The Flask and Blueprint classes now have a non-decorator method for adding34 custom template filters application wide,35 :meth:`flask.Flask.add_template_filter` and36 :meth:`flask.Blueprint.add_app_template_filter`.37- The :func:`flask.get_flashed_messages` function now allows rendering flashed38 message categories in separate blocks, through a ``category_filter``39 argument.403841Version 0.8.142-------------4344Bugfix release, release date to be decided
293 unmodified lines