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
Provenance
- Commit
81010bf- Tree
2ae57fc- Author
Ron DuPlain <ron.duplain@gmail.com>- Committer
Ron DuPlain <ron.duplain@gmail.com>- Parent
fa069f9
2 files changed+32 added−3 removed
modified:flask/helpers.py+29 added-2 removed
249 unmodified lines250 """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`.253 254- .. versionchanged: 0.3254+ .. versionchanged:: 0.3255 `category` parameter added.256 257 :param message: the message to be flashed.258 :param category: the category for the message. The following values11 unmodified lines270 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.273 274+ 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:278+279+ * `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.283+284 Example usage:285 286 .. sourcecode:: html+jinja287 288 {% for category, msg in get_flashed_messages(with_categories=true) %}289 <p class=flash-{{ category }}>{{ msg }}290 {% endfor %}291 292+ Example usage similar to http://twitter.github.com/bootstrap/#alerts:293+294+ .. sourcecode:: html+jinja295+296+ {% 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 %}308+309 .. versionchanged:: 0.3310 `with_categories` parameter added.311 285- .. versionchanged: 0.9312+ .. versionchanged:: 0.9313 `category_filter` parameter added.314 315 :param with_categories: set to `True` to also receive categories.316 :param category_filter: whitelist of categories to limit return values395 unmodified linesmodified:CHANGES+3 added-1 removed
32 unmodified lines33 - 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.40 38-41 Version 0.8.142 -------------43 44 Bugfix release, release date to be decided293 unmodified lines