Latest Version: 0.9.6.1

Returning early from a Mako template by Mike Orr


Language: Text only
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
[Append a subsection under Syntax]

Returning 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.

% if len(records) == 0:
No records found.
<%   return  %>
% endif

Or perhaps:

<%   if len(records) == 0:
         return
%>

Top