diff options
Diffstat (limited to 'doc/build/filtering.rst')
-rw-r--r-- | doc/build/filtering.rst | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/build/filtering.rst b/doc/build/filtering.rst index c8765d3..c657b01 100644 --- a/doc/build/filtering.rst +++ b/doc/build/filtering.rst @@ -152,6 +152,8 @@ The above will generate templates something like this: def render_body(context): context.write(myfilter(unicode("some text"))) +.. _expression_filtering_nfilter: + Turning off Filtering with the ``n`` Filter ------------------------------------------- @@ -171,6 +173,20 @@ will render ``myexpression`` with no filtering of any kind, and: will render ``myexpression`` using the ``trim`` filter only. +Including the ``n`` filter in a ``<%page>`` tag will only disable +``default_filters``. In effect this makes the filters from the tag replace +default filters instead of adding to them. For example: + +.. sourcecode:: mako + + <%page expression_filter="n, json.dumps"/> + data = {a: ${123}, b: ${"123"}}; + +will suppress turning the values into strings using the default filter, so that +``json.dumps`` (which requires ``imports=["import json"]`` or something +equivalent) can take the value type into account, formatting numbers as numeric +literals and strings as string literals. + Filtering Defs and Blocks ========================= |