<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <title>Designer Documentation &mdash; Jinja Documentation</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <link rel="stylesheet" href="style.css" type="text/css">
  <style type="text/css">
    .syntax  { background: #ffffff; }
.syntax .c { color: #888888 } /* Comment */
.syntax .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.syntax .k { color: #008800; font-weight: bold } /* Keyword */
.syntax .cm { color: #888888 } /* Comment.Multiline */
.syntax .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.syntax .c1 { color: #888888 } /* Comment.Single */
.syntax .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.syntax .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.syntax .ge { font-style: italic } /* Generic.Emph */
.syntax .gr { color: #aa0000 } /* Generic.Error */
.syntax .gh { color: #303030 } /* Generic.Heading */
.syntax .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.syntax .go { color: #888888 } /* Generic.Output */
.syntax .gp { color: #555555 } /* Generic.Prompt */
.syntax .gs { font-weight: bold } /* Generic.Strong */
.syntax .gu { color: #606060 } /* Generic.Subheading */
.syntax .gt { color: #aa0000 } /* Generic.Traceback */
.syntax .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.syntax .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.syntax .kp { color: #008800 } /* Keyword.Pseudo */
.syntax .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.syntax .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.syntax .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.syntax .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.syntax .na { color: #336699 } /* Name.Attribute */
.syntax .nb { color: #003388 } /* Name.Builtin */
.syntax .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.syntax .no { color: #003366; font-weight: bold } /* Name.Constant */
.syntax .nd { color: #555555 } /* Name.Decorator */
.syntax .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.syntax .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.syntax .nl { color: #336699; font-style: italic } /* Name.Label */
.syntax .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.syntax .py { color: #336699; font-weight: bold } /* Name.Property */
.syntax .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.syntax .nv { color: #336699 } /* Name.Variable */
.syntax .ow { color: #008800 } /* Operator.Word */
.syntax .w { color: #bbbbbb } /* Text.Whitespace */
.syntax .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.syntax .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.syntax .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.syntax .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.syntax .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.syntax .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.syntax .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.syntax .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.syntax .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.syntax .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.syntax .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.syntax .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.syntax .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.syntax .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.syntax .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.syntax .bp { color: #003388 } /* Name.Builtin.Pseudo */
.syntax .vc { color: #336699 } /* Name.Variable.Class */
.syntax .vg { color: #dd7700 } /* Name.Variable.Global */
.syntax .vi { color: #3333bb } /* Name.Variable.Instance */
.syntax .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
  </style>
</head>
<body>
  <div id="content">
    
      <h1 class="heading"><span>Jinja</span></h1>
      <h2 class="subheading">Designer Documentation</h2>
    
    
    <div id="toc">
      <h2>Navigation</h2>
      <ul>
        <li><a href="index.html">back to index</a></li>
      </ul>
      
        <h2>Contents</h2>
        <ul class="contents">
        
          <li><a href="#basics">Basics</a></li>
        
          <li><a href="#loops">Loops</a></li>
        
          <li><a href="#cycling">Cycling</a></li>
        
          <li><a href="#conditions">Conditions</a></li>
        
          <li><a href="#literals">Literals</a></li>
        
          <li><a href="#operators">Operators</a></li>
        
          <li><a href="#boolean-values">Boolean Values</a></li>
        
          <li><a href="#slicing">Slicing</a></li>
        
          <li><a href="#macros">Macros</a></li>
        
          <li><a href="#extended-macro-call">Extended Macro Call</a></li>
        
          <li><a href="#template-inclusion">Template Inclusion</a></li>
        
          <li><a href="#filtering-blocks">Filtering Blocks</a></li>
        
          <li><a href="#defining-variables">Defining Variables</a></li>
        
          <li><a href="#reserved-keywords">Reserved Keywords</a></li>
        
        </ul>
      
    </div>
    
    <div id="contentwrapper">
      <p>This part of the Jinja documentaton is meant for template designers.</p>
<div class="section">
<h2><a id="basics" name="basics">Basics</a></h2>
<p>The Jinja template language is designed to strike a balance between content
and application logic. Nevertheless you can use a python like statement
language. You don't have to know how Python works to create Jinja templates,
but if you know it you can use some additional statements you may know from
Python.</p>
<p>Here is a small example template:</p>
<div class="syntax"><pre><span class="cp">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span>
<span class="cp"> &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</span>
<span class="nt">&lt;html</span> <span class="na">xmlns=</span><span class="s">&quot;http://www.w3.org/1999/xhtml&quot;</span> <span class="na">lang=</span><span class="s">&quot;en&quot;</span> <span class="na">xml:lang=</span><span class="s">&quot;en&quot;</span><span class="nt">&gt;</span>
<span class="nt">&lt;head&gt;</span>
    <span class="nt">&lt;title&gt;</span>My Webpage<span class="nt">&lt;/title&gt;</span>
<span class="nt">&lt;/head&gt;</span>
<span class="nt">&lt;body&gt;</span>
    <span class="nt">&lt;ul</span> <span class="na">id=</span><span class="s">&quot;navigation&quot;</span><span class="nt">&gt;</span>
    <span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">navigation</span> <span class="cp">%}</span>
        <span class="nt">&lt;li&gt;&lt;a</span> <span class="na">href=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">item.href</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="nt">&gt;</span><span class="cp">{{</span> <span class="nv">item.caption</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="nt">&lt;/a&gt;&lt;/li&gt;</span>
    <span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
    <span class="nt">&lt;/ul&gt;</span>

    <span class="nt">&lt;h1&gt;</span>My Webpage<span class="nt">&lt;/h1&gt;</span>
    <span class="cp">{{</span> <span class="nv">variable</span> <span class="cp">}}</span>
<span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</pre></div>
<p>This covers the default settings. The application developer might have changed
the syntax from <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">foo</span> <span class="pre">%}</span></tt> to <tt class="docutils literal"><span class="pre">&lt;%</span> <span class="pre">foo</span> <span class="pre">%&gt;</span></tt> or something similar. This
documentation just covers the default values.</p>
<p>A variable looks like <tt class="docutils literal"><span class="pre">{{</span> <span class="pre">foobar</span> <span class="pre">}}</span></tt> where foobar is the variable name. Inside
of statements (<tt class="docutils literal"><span class="pre">{%</span> <span class="pre">some</span> <span class="pre">content</span> <span class="pre">here</span> <span class="pre">%}</span></tt>) variables are just normal names
without the braces around it. In fact <tt class="docutils literal"><span class="pre">{{</span> <span class="pre">foobar</span> <span class="pre">}}</span></tt> is just an alias for
the statement <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">print</span> <span class="pre">foobar</span> <span class="pre">%}</span></tt>.</p>
<p>Variables are coming from the context provided by the application. Normally there
should be a documentation regarding the context contents but if you want to know
the content of the current context, you can add this to your template:</p>
<div class="syntax"><pre><span class="nt">&lt;pre&gt;</span><span class="cp">{{</span> <span class="nv">debug</span><span class="o">()|</span><span class="nf">e</span> <span class="cp">}}</span><span class="nt">&lt;/pre&gt;</span>
</pre></div>
<p>A context isn't flat which means that each variable can has subvariables, as long
as it is representable as python data structure. You can access attributes of
a variable using the dot and bracket operators. The following examples show
this:</p>
<div class="syntax"><pre><span class="cp">{{</span> <span class="nv">user.username</span> <span class="cp">}}</span><span class="x"></span>
<span class="x">    is the same as</span>
<span class="cp">{{</span> <span class="nv">user</span><span class="o">[</span><span class="s1">&#39;username&#39;</span><span class="o">]</span> <span class="cp">}}</span><span class="x"></span>
<span class="x">    you can also use a variable to access an attribute:</span>
<span class="cp">{{</span> <span class="nv">users</span><span class="o">[</span><span class="nv">current_user</span><span class="o">]</span><span class="nv">.username</span> <span class="cp">}}</span><span class="x"></span>
<span class="x">    If you have numerical indices you have to use the [] syntax:</span>
<span class="cp">{{</span> <span class="nv">users</span><span class="o">[</span><span class="m">0</span><span class="o">]</span><span class="nv">.username</span> <span class="cp">}}</span><span class="x"></span>
</pre></div>
<p><em>new in Jinja 1.2</em>: You can now use django like attributes for integer
indices.  Thus <tt class="docutils literal"><span class="pre">{{</span> <span class="pre">foo.0</span> <span class="pre">}}</span></tt> is equivalent to <tt class="docutils literal"><span class="pre">{{</span> <span class="pre">foo[0]</span> <span class="pre">}}</span></tt>.</p>
</div>
<div class="section">
<h2><a id="loops" name="loops">Loops</a></h2>
<p>To iterate over a sequence, you can use the <cite>for</cite> loop. It basically looks like a
normal Python <cite>for</cite> loop and works pretty much the same:</p>
<div class="syntax"><pre><span class="nt">&lt;h1&gt;</span>Members<span class="nt">&lt;/h1&gt;</span>
<span class="nt">&lt;ul&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">user</span> <span class="k">in</span> <span class="nv">users</span> <span class="cp">%}</span>
  <span class="nt">&lt;li&gt;</span><span class="cp">{{</span> <span class="nb">loop</span><span class="nv">.index</span> <span class="cp">}}</span> / <span class="cp">{{</span> <span class="nb">loop</span><span class="nv">.length</span> <span class="cp">}}</span> - <span class="cp">{{</span> <span class="nv">user.username</span><span class="o">|</span><span class="nf">escape</span> <span class="cp">}}</span><span class="nt">&lt;/li&gt;</span>
<span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span>
  <span class="nt">&lt;li&gt;&lt;em&gt;</span>no users found<span class="nt">&lt;/em&gt;&lt;/li&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
<span class="nt">&lt;/ul&gt;</span>
</pre></div>
<p><em>Important</em> Contrary to Python is the optional <cite>else</cite> block only
executed if there was no iteration because the sequence was empty.</p>
<p>Inside of a <cite>for</cite> loop block you can access some special variables:</p>
<table border="1" class="docutils">
<colgroup>
<col width="35%" />
<col width="65%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Variable</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><cite>loop.index</cite></td>
<td>The current iteration of the loop.</td>
</tr>
<tr><td><cite>loop.index0</cite></td>
<td>The current iteration of the loop,
starting counting by 0.</td>
</tr>
<tr><td><cite>loop.revindex</cite></td>
<td>The number of iterations from the end
of the loop.</td>
</tr>
<tr><td><cite>loop.revindex0</cite></td>
<td>The number of iterations from the end
of the loop, starting counting by 0.</td>
</tr>
<tr><td><cite>loop.first</cite></td>
<td>True if first iteration.</td>
</tr>
<tr><td><cite>loop.last</cite></td>
<td>True if last iteration.</td>
</tr>
<tr><td><cite>loop.even</cite></td>
<td>True if current iteration is even.</td>
</tr>
<tr><td><cite>loop.odd</cite></td>
<td>True if current iteration is odd.</td>
</tr>
<tr><td><cite>loop.length</cite></td>
<td>Total number of items in the sequence.</td>
</tr>
<tr><td><cite>loop.parent</cite></td>
<td>The context of the parent loop.</td>
</tr>
</tbody>
</table>
<p>Loops also support recursion. Let's assume you have a sitemap where each item
might have a number of child items. A template for that could look like this:</p>
<div class="syntax"><pre><span class="nt">&lt;h1&gt;</span>Sitemap
<span class="nt">&lt;ul</span> <span class="na">id=</span><span class="s">&quot;sitemap&quot;</span><span class="nt">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">sitemap</span> <span class="k">recursive</span> <span class="cp">%}</span>
  <span class="nt">&lt;li&gt;&lt;a</span> <span class="na">href=</span><span class="s">&quot;</span><span class="cp">{{</span> <span class="nv">item.url</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="s">&quot;</span><span class="nt">&gt;</span><span class="cp">{{</span> <span class="nv">item.title</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="nt">&lt;/a&gt;</span>
  <span class="cp">{%</span> <span class="k">if</span> <span class="nv">item.children</span> <span class="cp">%}</span><span class="nt">&lt;ul&gt;</span><span class="cp">{{</span> <span class="nb">loop</span><span class="o">(</span><span class="nv">item.children</span><span class="o">)</span> <span class="cp">}}</span><span class="nt">&lt;/ul&gt;</span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="nt">&lt;/li&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
<span class="nt">&lt;/ul&gt;</span>
</pre></div>
<p>What happens here? Basically the first thing that is different to a normal
loop is the additional <tt class="docutils literal"><span class="pre">recursive</span></tt> modifier in the <cite>for</cite>-loop declaration.
It tells the template engine that we want recursion. If recursion is enabled
the special <cite>loop</cite> variable is callable. If you call it with a sequence it will
automatically render the loop at that position with the new sequence as argument.</p>
</div>
<div class="section">
<h2><a id="cycling" name="cycling">Cycling</a></h2>
<p>Sometimes you might want to have different text snippets for each row in a list,
for example to have alternating row colors. You can easily do this by using the
<tt class="docutils literal"><span class="pre">{%</span> <span class="pre">cycle</span> <span class="pre">%}</span></tt> tag:</p>
<div class="syntax"><pre><span class="nt">&lt;ul</span> <span class="na">id=</span><span class="s">&quot;messages&quot;</span><span class="nt">&gt;</span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">message</span> <span class="k">in</span> <span class="nv">messages</span> <span class="cp">%}</span>
  <span class="nt">&lt;li</span> <span class="na">class=</span><span class="s">&quot;</span><span class="cp">{%</span> <span class="k">cycle</span> <span class="s1">&#39;row1&#39;</span><span class="o">,</span> <span class="s1">&#39;row2&#39;</span> <span class="cp">%}</span><span class="s">&quot;</span><span class="nt">&gt;</span><span class="cp">{{</span> <span class="nv">message</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="nt">&lt;/li&gt;</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
<span class="nt">&lt;/ul&gt;</span>
</pre></div>
<p>Each time Jinja encounters a <cite>cycle</cite> tag it will cycle through the list
of given items and return the next one. If you pass it one item jinja assumes
that this item is a sequence from the context and uses this:</p>
<div class="syntax"><pre><span class="nt">&lt;li</span> <span class="na">style=</span><span class="s">&quot;color: </span><span class="cp">{%</span> <span class="k">cycle</span> <span class="nv">rowcolors</span> <span class="cp">%}</span><span class="s">&quot;</span><span class="nt">&gt;</span>...<span class="nt">&lt;/li&gt;</span>
</pre></div>
</div>
<div class="section">
<h2><a id="conditions" name="conditions">Conditions</a></h2>
<p>Jinja supports Python-like <cite>if</cite> / <cite>elif</cite> / <cite>else</cite> constructs:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">if</span> <span class="nv">user.active</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">    user </span><span class="cp">{{</span> <span class="nv">user.name</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="x"> is active.</span>
<span class="cp">{%</span> <span class="k">elif</span> <span class="nv">user.deleted</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">    user </span><span class="cp">{{</span> <span class="nv">user.name</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="x"> was deleted some time ago.</span>
<span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">    i don&#39;t know what&#39;s wrong with </span><span class="cp">{{</span> <span class="nv">user.username</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
<p>If the user is active the first block is rendered. If not and the user was
deleted the second one, in all other cases the third one.</p>
<p>You can also use comparison operators:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">if</span> <span class="nv">amount</span> <span class="o">&lt;</span> <span class="m">0</span> <span class="cp">%}</span>
    <span class="nt">&lt;span</span> <span class="na">style=</span><span class="s">&quot;color: red&quot;</span><span class="nt">&gt;</span><span class="cp">{{</span> <span class="nv">amount</span> <span class="cp">}}</span><span class="nt">&lt;/span&gt;</span>
<span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span>
    <span class="nt">&lt;span</span> <span class="na">style=</span><span class="s">&quot;color: black&quot;</span><span class="nt">&gt;</span><span class="cp">{{</span> <span class="nv">amount</span> <span class="cp">}}</span><span class="nt">&lt;/span&gt;</span>
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>
</pre></div>
<div class="admonition-note admonition">
<p class="first admonition-title">Note</p>
<p class="last">Of course you can use <cite>or</cite> / <cite>and</cite> and parentheses to create more complex
conditions, but usually the logic is already handled in the application and
you don't have to create such complex constructs in the template code. However
in some situations it might be a good thing to have the abilities to create
them.</p>
</div>
</div>
<div class="section">
<h2><a id="literals" name="literals">Literals</a></h2>
<p>For most of the builtin python types, literals exist in Jinja. The following
table shows which syntax elements are supported:</p>
<blockquote>
<table border="1" class="docutils">
<colgroup>
<col width="31%" />
<col width="69%" />
</colgroup>
<tbody valign="top">
<tr><td><tt class="docutils literal"><span class="pre">&quot;text&quot;</span> <span class="pre">/</span> <span class="pre">'text'</span></tt></td>
<td>work like python's unicode literals (u'text').</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">42</span></tt></td>
<td>integer literls.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">42.0</span></tt></td>
<td>float literals (exponents are not supported and
before and after the dot digits must be present)</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">[1,</span> <span class="pre">'two',</span> <span class="pre">none]</span></tt></td>
<td>list literal</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">(),</span> <span class="pre">(1,),</span> <span class="pre">(1,</span> <span class="pre">2)</span></tt></td>
<td>tuple literals. (tuples work like lists but consume
less memory and are not modifyable.)</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">{'foo':</span> <span class="pre">'bar'}</span></tt></td>
<td>dictionary literal</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">&#64;/expr/flags</span></tt></td>
<td>regular expression literals. <tt class="docutils literal"><span class="pre">&#64;/expr/flags</span></tt> is
equivalent to <tt class="docutils literal"><span class="pre">re.compile('(?flags)expr')</span></tt> in
python.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">&#64;(1,</span> <span class="pre">2,</span> <span class="pre">3)</span></tt></td>
<td>set literal. <tt class="docutils literal"><span class="pre">&#64;(1,</span> <span class="pre">2,</span> <span class="pre">3)</span></tt> in Jinja is is equal to
<tt class="docutils literal"><span class="pre">set([1,</span> <span class="pre">2,</span> <span class="pre">3])</span></tt> in python.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">true</span> <span class="pre">/</span> <span class="pre">false</span></tt></td>
<td>corresponds to <cite>True</cite> and <cite>False</cite> in python.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">none</span></tt></td>
<td>corresponds to <cite>None</cite> in python.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">undefined</span></tt></td>
<td>special Jinja undefined singleton.</td>
</tr>
</tbody>
</table>
</blockquote>
<div class="admonition-common-pitfalls admonition">
<p class="first admonition-title">Common Pitfalls</p>
<p class="last">Keep in mind that Jinja literals, keywords and functions are all lowercase.
If you're used to Python you probably tried to write <cite>True</cite> which evaluates
to undefined because it simply does not exist.  The correct name for the
true value is just <cite>true</cite> (lowercase).</p>
</div>
</div>
<div class="section">
<h2><a id="operators" name="operators">Operators</a></h2>
<p>Inside <tt class="docutils literal"><span class="pre">{{</span> <span class="pre">variable</span> <span class="pre">}}</span></tt> blocks, <cite>if</cite> conditions and many other parts you can
can use expressions. In expressions you can use any of the following operators:</p>
<blockquote>
<table border="1" class="docutils">
<colgroup>
<col width="9%" />
<col width="91%" />
</colgroup>
<tbody valign="top">
<tr><td><tt class="docutils literal"><span class="pre">+</span></tt></td>
<td>add the right operand to the left one.
<tt class="docutils literal"><span class="pre">{{</span> <span class="pre">1</span> <span class="pre">+</span> <span class="pre">2</span> <span class="pre">}}</span></tt> would return <tt class="docutils literal"><span class="pre">3</span></tt>.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">-</span></tt></td>
<td>subtract the right operand from the left one.
<tt class="docutils literal"><span class="pre">{{</span> <span class="pre">1</span> <span class="pre">-</span> <span class="pre">1</span> <span class="pre">}}</span></tt> would return <tt class="docutils literal"><span class="pre">0</span></tt>.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">/</span></tt></td>
<td>divide the left operand by the right one.
<tt class="docutils literal"><span class="pre">{{</span> <span class="pre">1</span> <span class="pre">/</span> <span class="pre">2</span> <span class="pre">}}</span></tt> would return <tt class="docutils literal"><span class="pre">0.5</span></tt>.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">//</span></tt></td>
<td>divide the left operand by the right one and return a truncated
integer result: <tt class="docutils literal"><span class="pre">{{</span> <span class="pre">20</span> <span class="pre">//</span> <span class="pre">7</span> <span class="pre">}}</span></tt> is <tt class="docutils literal"><span class="pre">2</span></tt>.
<em>added in Jinja 1.1</em></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">~</span></tt></td>
<td>string concatenate a value with another one.  <tt class="docutils literal"><span class="pre">{{</span> <span class="pre">foo</span> <span class="pre">~</span> <span class="pre">bar</span> <span class="pre">}}</span></tt>
is equivalent to <tt class="docutils literal"><span class="pre">{{&nbsp;foo|string</span> <span class="pre">+</span> <span class="pre">bar|string</span> <span class="pre">}}</span></tt>.  <em>added in
Jinja 1.1</em></td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">*</span></tt></td>
<td>multiply the left operand with the right one.
<tt class="docutils literal"><span class="pre">{{</span> <span class="pre">2</span> <span class="pre">*</span> <span class="pre">2</span> <span class="pre">}}</span></tt> would return <tt class="docutils literal"><span class="pre">4</span></tt>.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">**</span></tt></td>
<td>raise the left operand to the power of the right
operand. <tt class="docutils literal"><span class="pre">{{</span> <span class="pre">2**3</span> <span class="pre">}}</span></tt> would return <tt class="docutils literal"><span class="pre">8</span></tt>.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">%</span></tt></td>
<td>calculate the remainder of an integer division between the
left and right operand: <tt class="docutils literal"><span class="pre">{{</span> <span class="pre">11</span> <span class="pre">%</span> <span class="pre">7</span> <span class="pre">}}</span></tt> is <tt class="docutils literal"><span class="pre">4</span></tt>.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">in</span></tt></td>
<td>perform sequence membership test. <tt class="docutils literal"><span class="pre">{{</span> <span class="pre">1</span> <span class="pre">in</span> <span class="pre">[1,2,3]</span> <span class="pre">}}</span></tt> would
return true.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">is</span></tt></td>
<td>perform a test on the value. See the section about
tests for more information.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">|</span></tt></td>
<td>apply a filter on the value. See the section about
filters for more information.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">and</span></tt></td>
<td>return true if the left and the right operand is true.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">or</span></tt></td>
<td>return true if the left or the right operand is true.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">not</span></tt></td>
<td>negate a statement (see below)</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">()</span></tt></td>
<td>call a callable: <tt class="docutils literal"><span class="pre">{{</span> <span class="pre">user.get_username()</span> <span class="pre">}}</span></tt>. Inside of the
parentheses you can use variables: <tt class="docutils literal"><span class="pre">{{</span> <span class="pre">user.get(username)</span> <span class="pre">}}</span></tt>.</td>
</tr>
</tbody>
</table>
</blockquote>
<p>Note that there is no support for any bit operations or something similar.</p>
<ul class="simple">
<li>special note regarding <cite>not</cite>: The <cite>is</cite> and <cite>in</cite> operators support negation
using an infix notation too: <tt class="docutils literal"><span class="pre">foo</span> <span class="pre">is</span> <span class="pre">not</span> <span class="pre">bar</span></tt> and <tt class="docutils literal"><span class="pre">foo</span> <span class="pre">not</span> <span class="pre">in</span> <span class="pre">bar</span></tt>
instead of <tt class="docutils literal"><span class="pre">not</span> <span class="pre">foo</span> <span class="pre">is</span> <span class="pre">bar</span></tt> and <tt class="docutils literal"><span class="pre">not</span> <span class="pre">foo</span> <span class="pre">in</span> <span class="pre">bar</span></tt>. All other expressions
require a prefix notation: <tt class="docutils literal"><span class="pre">not</span> <span class="pre">(foo</span> <span class="pre">and</span> <span class="pre">bar)</span></tt>.</li>
</ul>
<p>With Jinja 1.2 onwards it's possible to replace basic if/else blocks with the
inline <cite>if</cite> / <cite>else</cite> expression.  The following two examples evaluate to the
same:</p>
<div class="syntax"><pre><span class="cp">{{</span> <span class="s2">&quot;something&quot;</span> <span class="nv">if</span> <span class="nv">expr</span> <span class="nv">else</span> <span class="s2">&quot;otherthing&quot;</span> <span class="cp">}}</span><span class="x"></span>

<span class="cp">{%</span> <span class="k">if</span> <span class="nv">expr</span> <span class="cp">%}</span><span class="x">something</span><span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span><span class="x">otherthing</span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
<div class="section">
<h2><a id="boolean-values" name="boolean-values">Boolean Values</a></h2>
<p>In If-Conditions Jinja performs a boolean check. All empty values (eg: empty
lists <tt class="docutils literal"><span class="pre">[]</span></tt>, empty dicts <tt class="docutils literal"><span class="pre">{}</span></tt> etc) evaluate to <cite>false</cite>. Numbers that are
equal to <cite>0</cite>/<cite>0.00</cite> are considered <cite>false</cite> too. The boolean value of other
objects depends on the behavior the application developer gave it. Usually
items are <cite>true</cite>.</p>
<p>Here some examples that should explain it:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">if</span> <span class="o">[]</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">    will always be false because it&#39;s an empty list</span>

<span class="cp">{%</span> <span class="k">if</span> <span class="o">{}</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">    false too.</span>

<span class="cp">{%</span> <span class="k">if</span> <span class="o">[</span><span class="s1">&#39;foo&#39;</span><span class="o">]</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">    this is true. Because the list is not empty.</span>

<span class="cp">{%</span> <span class="k">if</span> <span class="s2">&quot;foobar&quot;</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">    this is also true because the string is not empty.</span>
</pre></div>
</div>
<div class="section">
<h2><a id="slicing" name="slicing">Slicing</a></h2>
<p>Some objects support slicing operations. For example lists:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">items</span><span class="o">[:</span><span class="m">5</span><span class="o">]</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">    This will only iterate over the first 5 items of the list</span>

<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">items</span><span class="o">[</span><span class="m">5</span><span class="o">:</span><span class="m">10</span><span class="o">]</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">    This will only iterate from item 5 to 10.</span>

<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">items</span><span class="o">[:</span><span class="m">10</span><span class="o">:</span><span class="m">2</span><span class="o">]</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">    This will only yield items from start to ten and only returing</span>
<span class="x">    even items.</span>
</pre></div>
<p>For more informations about slicing have a look at the <a class="reference" href="http://diveintopython.org/native_data_types/lists.html#odbchelper.list.slice">slicing chapter</a>
in the &quot;Dive into Python&quot; e-book.</p>
</div>
<div class="section">
<h2><a id="macros" name="macros">Macros</a></h2>
<p>If you want to use a partial template in more than one place, you might want to
create a macro from it:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">macro</span> <span class="nv">show_user</span> <span class="nv">user</span> <span class="cp">%}</span>
  <span class="nt">&lt;h1&gt;</span><span class="cp">{{</span> <span class="nv">user.name</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="nt">&lt;/h1&gt;</span>
  <span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;text&quot;</span><span class="nt">&gt;</span>
    <span class="cp">{{</span> <span class="nv">user.description</span> <span class="cp">}}</span>
  <span class="nt">&lt;/div&gt;</span>
<span class="cp">{%</span> <span class="k">endmacro</span> <span class="cp">%}</span>
</pre></div>
<p>Now you can use it from everywhere in the code by passing it an item:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">for</span> <span class="nv">user</span> <span class="k">in</span> <span class="nv">users</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">    </span><span class="cp">{{</span> <span class="nv">show_user</span><span class="o">(</span><span class="nv">user</span><span class="o">)</span> <span class="cp">}}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
<p>You can also specify more than one value:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">macro</span> <span class="nv">show_dialog</span> <span class="nv">title</span><span class="o">,</span> <span class="nv">text</span> <span class="cp">%}</span>
  <span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;dialog&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;h1&gt;</span><span class="cp">{{</span> <span class="nv">title</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="nt">&lt;/h1&gt;</span>
    <span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;text&quot;</span><span class="nt">&gt;</span><span class="cp">{{</span> <span class="nv">text</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="nt">&lt;/div&gt;</span>
  <span class="nt">&lt;/div&gt;</span>
<span class="cp">{%</span> <span class="k">endmacro</span> <span class="cp">%}</span>

<span class="cp">{{</span> <span class="nv">show_dialog</span><span class="o">(</span><span class="s1">&#39;Warning&#39;</span><span class="o">,</span> <span class="s1">&#39;something went wrong i guess&#39;</span><span class="o">)</span> <span class="cp">}}</span>
</pre></div>
<p><em>Improvements in Jinja 1.1</em>:</p>
<blockquote>
<p>Starting with Jinja 1.1 it's possible to use optional parentheses
around the macro arguments:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">macro</span> <span class="nv">foo</span><span class="o">(</span><span class="nv">a</span><span class="o">,</span> <span class="nv">b</span><span class="o">)</span> <span class="cp">%}</span>
    ...
<span class="cp">{%</span> <span class="k">endmacro</span> <span class="cp">%}</span>
</pre></div>
<p>Additionally extra arguments passed to the macro end up in the
special variable <cite>varargs</cite>. So you can have a macro like this:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">macro</span> <span class="nv">make_list</span><span class="o">()</span> <span class="cp">%}</span>
  <span class="cp">{%</span> <span class="k">if</span> <span class="nv">varargs</span> <span class="cp">%}</span>
  <span class="nt">&lt;ul&gt;</span>
    <span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">varargs</span> <span class="cp">%}</span>
    <span class="nt">&lt;li&gt;</span><span class="cp">{{</span> <span class="nv">item</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="nt">&lt;/li&gt;</span>
    <span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
  <span class="nt">&lt;/ul&gt;</span>
  <span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>
<span class="cp">{%</span> <span class="k">endmacro</span> <span class="cp">%}</span>

<span class="cp">{{</span> <span class="nv">make_list</span><span class="o">(</span><span class="s2">&quot;John&quot;</span><span class="o">,</span> <span class="s2">&quot;Jane&quot;</span><span class="o">,</span> <span class="s2">&quot;Marcus&quot;</span><span class="o">,</span> <span class="s2">&quot;Heinrich&quot;</span><span class="o">)</span> <span class="cp">}}</span>
</pre></div>
<p>If a macro parameter is called <cite>varargs</cite> the additional extra
arguments are not accessible.</p>
</blockquote>
<p>For information regarding the visibility of macros have a look at the
<a class="reference" href="./scopes.html">Scopes and Variable Behavior</a> section.</p>
</div>
<div class="section">
<h2><a id="extended-macro-call" name="extended-macro-call">Extended Macro Call</a></h2>
<p><em>new in Jinja 1.1</em></p>
<p>Jinja 1.1 adds a new special tag that you can use to pass some evaluable
template code to a macro. Here an example macro that uses the features of
the <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">call</span> <span class="pre">%}</span></tt> tag:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">macro</span> <span class="nv">dialog</span> <span class="nv">title</span> <span class="cp">%}</span>
  <span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;dialog&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;h3&gt;</span><span class="cp">{{</span> <span class="nv">title</span> <span class="cp">}}</span><span class="nt">&lt;/h3&gt;</span>
    <span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;text&quot;</span><span class="nt">&gt;</span>
      <span class="cp">{{</span> <span class="nv">caller</span><span class="o">()</span> <span class="cp">}}</span>
    <span class="nt">&lt;/div&gt;</span>
  <span class="nt">&lt;/div&gt;</span>
<span class="cp">{%</span> <span class="k">endmacro</span> <span class="cp">%}</span>
</pre></div>
<p>Called the normal way <cite>caller</cite> will be undefined, but if you call it
using the new <cite>{% call %}</cite> tag you can pass it some data:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">call</span> <span class="nv">dialog</span><span class="o">(</span><span class="s1">&#39;Hello World&#39;</span><span class="o">)</span> <span class="cp">%}</span>
    This is an example dialog
<span class="cp">{%</span> <span class="k">endcall</span> <span class="cp">%}</span>
</pre></div>
<p>Now the data wrapped will be inserted where you put the <cite>caller</cite> call.</p>
<p>If you pass <cite>caller()</cite> some keyword arguments those are added to the
namespace of the wrapped template data:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">macro</span> <span class="nv">makelist</span> <span class="nv">items</span> <span class="cp">%}</span>
  <span class="nt">&lt;ul&gt;</span>
  <span class="cp">{%</span>- <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">items</span> <span class="cp">%}</span>
    <span class="nt">&lt;li&gt;</span><span class="cp">{{</span> <span class="nv">caller</span><span class="o">(</span><span class="nv">item</span><span class="o">=</span><span class="nv">item</span><span class="o">)</span> <span class="cp">}}</span><span class="nt">&lt;/li&gt;</span>
  <span class="cp">{%</span>- <span class="k">endfor</span> <span class="cp">%}</span>
  <span class="nt">&lt;/ul&gt;</span>
<span class="cp">{%</span>- <span class="k">endmacro</span> <span class="cp">%}</span>

<span class="cp">{%</span> <span class="k">call</span> <span class="nv">makelist</span><span class="o">([</span><span class="m">1</span><span class="o">,</span> <span class="m">2</span><span class="o">,</span> <span class="m">3</span><span class="o">,</span> <span class="m">4</span><span class="o">,</span> <span class="m">5</span><span class="o">,</span> <span class="m">6</span><span class="o">])</span> -<span class="cp">%}</span>
  [[<span class="cp">{{</span> <span class="nv">item</span> <span class="cp">}}</span>]]
<span class="cp">{%</span>- <span class="k">endcall</span> <span class="cp">%}</span>
</pre></div>
<p>This will then produce this output:</p>
<div class="syntax"><pre><span class="nt">&lt;ul&gt;</span>
  <span class="nt">&lt;li&gt;</span>[[1]]<span class="nt">&lt;/li&gt;</span>
  <span class="nt">&lt;li&gt;</span>[[2]]<span class="nt">&lt;/li&gt;</span>
  <span class="nt">&lt;li&gt;</span>[[3]]<span class="nt">&lt;/li&gt;</span>
  <span class="nt">&lt;li&gt;</span>[[4]]<span class="nt">&lt;/li&gt;</span>
  <span class="nt">&lt;li&gt;</span>[[5]]<span class="nt">&lt;/li&gt;</span>
  <span class="nt">&lt;li&gt;</span>[[6]]<span class="nt">&lt;/li&gt;</span>
<span class="nt">&lt;/ul&gt;</span>
</pre></div>
</div>
<div class="section">
<h2><a id="template-inclusion" name="template-inclusion">Template Inclusion</a></h2>
<p>You can load another template at a given position using <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">include</span> <span class="pre">%}</span></tt>.
Usually it's a better idea to use inheritance but if you for example want to
load macros, <cite>include</cite> works better than <cite>extends</cite>:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">include</span> <span class="s2">&quot;myhelpers.html&quot;</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{{</span> <span class="nv">my_helper</span><span class="o">(</span><span class="s2">&quot;foo&quot;</span><span class="o">)</span> <span class="cp">}}</span><span class="x"></span>
</pre></div>
<p>If you define a macro called <tt class="docutils literal"><span class="pre">my_helper</span></tt> in <tt class="docutils literal"><span class="pre">myhelpers.html</span></tt>, you can now
use it from the template as shown above.</p>
<p>Please keep in mind that include does not render the template indenpendently
but includes the processing instructions into the current template. Thus if the
included template contains a <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">extends</span> <span class="pre">%}</span></tt> tag it also affects the current
template.</p>
<p>This is intended because it makes it possible to include macros from other
templates.</p>
<p><em>new in Jinja 1.1</em> you can now render an included template to a string that is
evaluated in an indepdendent environment by calling <cite>rendertemplate</cite>. See the
documentation for this function in the <a class="reference" href="./builtins.html">builtins</a> documentation.</p>
</div>
<div class="section">
<h2><a id="filtering-blocks" name="filtering-blocks">Filtering Blocks</a></h2>
<p>Sometimes it could be a good idea to filter a complete block of text. For
example, if you want to escape some html code:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">filter</span> <span class="nf">escape</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">    &lt;html&gt;</span>
<span class="x">      &lt;code&gt;goes here&lt;/code&gt;</span>
<span class="x">    &lt;/html&gt;</span>
<span class="cp">{%</span> <span class="k">endfilter</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
<p>Of course you can chain filters too:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">filter</span> <span class="nf">lower</span><span class="o">|</span><span class="nf">escape</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">    &lt;B&gt;SOME TEXT&lt;/B&gt;</span>
<span class="cp">{%</span> <span class="k">endfilter</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
<p>returns <tt class="docutils literal"><span class="pre">&quot;&amp;lt;b&amp;gt;some</span> <span class="pre">text&amp;lt;/b&amp;gt;&quot;</span></tt>.</p>
</div>
<div class="section">
<h2><a id="defining-variables" name="defining-variables">Defining Variables</a></h2>
<p>You can also define variables in the namespace using the <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">set</span> <span class="pre">%}</span></tt> tag:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">set</span> <span class="nv">foo</span> <span class="o">=</span> <span class="s1">&#39;foobar&#39;</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{{</span> <span class="nv">foo</span> <span class="cp">}}</span><span class="x"></span>
</pre></div>
<p>This should ouput <tt class="docutils literal"><span class="pre">foobar</span></tt>.</p>
<p>For information regarding the visibility of variables have a look at the
<a class="reference" href="./scopes.html">Scopes and Variable Behavior</a> section.</p>
</div>
<div class="section">
<h2><a id="reserved-keywords" name="reserved-keywords">Reserved Keywords</a></h2>
<p>Jinja has some keywords you cannot use a variable names. This limitation
exists to make templates look coherent. Syntax highlighters won't mess things
up and you won't have the situation that some names work depending on the
context.</p>
<p>The following keywords exist and cannot be used as identifiers:</p>
<blockquote>
<cite>and</cite>, <cite>block</cite>, <cite>cycle</cite>, <cite>elif</cite>, <cite>else</cite>, <cite>endblock</cite>, <cite>endfilter</cite>,
<cite>endfor</cite>, <cite>endif</cite>, <cite>endmacro</cite>, <cite>endraw</cite>, <cite>endtrans</cite>, <cite>extends</cite>, <cite>filter</cite>,
<cite>for</cite>, <cite>if</cite>, <cite>in</cite>, <cite>include</cite>, <cite>is</cite>, <cite>macro</cite>, <cite>not</cite>, <cite>or</cite>, <cite>pluralize</cite>,
<cite>print</cite>, <cite>raw</cite>, <cite>recursive</cite>, <cite>set</cite>, <cite>trans</cite>, <cite>call</cite>, <cite>endcall</cite></blockquote>
<p>If you want to use such a name you have to prefix or suffix it or use
alternative names:</p>
<div class="syntax"><pre><span class="cp">{%</span> <span class="k">for</span> <span class="nv">macro_</span> <span class="k">in</span> <span class="nv">macros</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">    </span><span class="cp">{{</span> <span class="nv">macro_</span><span class="o">(</span><span class="s1">&#39;foo&#39;</span><span class="o">)</span> <span class="cp">}}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>

    </div>
  </div>
</body>
<!-- generated on: 2007-11-17 18:18:03.239368
     file id: designerdoc -->
</html>