aboutsummaryrefslogtreecommitdiffstats
path: root/doc/build/syntax.rst
diff options
context:
space:
mode:
authorCody Taylor <codemister99@yahoo.com>2015-03-24 20:57:02 -0400
committerCody Taylor <codemister99@yahoo.com>2015-03-24 20:57:47 -0400
commit52e8c0a3deaae9017c76a17196aeac8b027b933e (patch)
tree77179e4d936cd6e6de938ef98bc1e8fc5f88c0a1 /doc/build/syntax.rst
parentb6d0479034e4f379576caa6eb9ef3e32369c333f (diff)
downloadexternal_python_mako-52e8c0a3deaae9017c76a17196aeac8b027b933e.tar.gz
external_python_mako-52e8c0a3deaae9017c76a17196aeac8b027b933e.tar.bz2
external_python_mako-52e8c0a3deaae9017c76a17196aeac8b027b933e.zip
Add STOP_RENDERING keyword; exiting of a template.
Signed-off-by: Cody Taylor <codemister99@yahoo.com>
Diffstat (limited to 'doc/build/syntax.rst')
-rw-r--r--doc/build/syntax.rst21
1 files changed, 15 insertions, 6 deletions
diff --git a/doc/build/syntax.rst b/doc/build/syntax.rst
index fe4a860..7ec68cb 100644
--- a/doc/build/syntax.rst
+++ b/doc/build/syntax.rst
@@ -443,19 +443,19 @@ Mako:
<%def name="x()">${x}</%def>
</%text>
-Returning Early from a Template
-===============================
+Exiting Early from a Template
+=============================
Sometimes you want to stop processing a template or ``<%def>``
method in the middle and just use the text you've accumulated so
-far. You can use a ``return`` statement inside a Python
-block to do that.
+far. You can ``return`` the ``STOP_RENDERING`` value inside a Python
+block to exit the current rendering process.
.. sourcecode:: mako
% if not len(records):
No records found.
- <% return %>
+ <% return STOP_RENDERING %>
% endif
Or perhaps:
@@ -464,6 +464,15 @@ Or perhaps:
<%
if not len(records):
- return
+ return STOP_RENDERING
%>
+In older versions, return an empty string instead to avoid having
+``None`` in your rendered template:
+
+.. sourcecode:: mako
+
+ <% return '' %>
+
+.. versionadded:: 1.0.2
+