Skip to content
Myr

[svn] fixed loop context bug, added new jinja webpage

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent e55ed10 · Browse files · 20 files+737 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

20 files+737 added−8 removed

  • other:+737 added−8 removed

20 files+737 added−8 removed

modified:jinja/__init__.py+3 added
6 unmodified lines
7 :license: BSD, see LICENSE for more details.8"""9from jinja.environment import Environment10from jinja.loaders import *111213from_string = Environment().from_string
modified:jinja/datastructure.py+7 added-1 removed
64 unmodified lines
6566 def __float__(self):67 return 16869 def __call__(self, *args, **kwargs):70 return self717273Undefined = UndefinedType()747576class Deferred(object):
139 unmodified lines
216 if self.loop_function is not None:217 return self.loop_function(seq)218 return Undefined219220 def __repr__(self):221 return str(self._stack)222223224class CycleContext(object):225 """226 Helper class used for cycling.227 """
40 unmodified lines
268 return False269 return True270271 eos = property(lambda x: not x.__nonzero__(), doc=__nonzero__.__doc__)266272 273 def next(self):274 """Return the next token from the stream."""275 if self._pushed:276 rv = self._pushed.pop()
28 unmodified lines
modified:jinja/environment.py+6 added-7 removed
131 unmodified lines
132 def get_attribute(self, obj, name):133 """134 Get the attribute name from obj.135 """136 if name in obj:136 try:137 return obj[name]138 elif hasattr(obj, name):139 rv = getattr(obj, name)140 r = getattr(obj, 'jinja_allowed_attributes', None)141 if r is not None:142 if name not in r:138 except (TypeError, KeyError, IndexError):139 if hasattr(obj, name):140 r = getattr(obj, 'jinja_allowed_attributes', None)141 if r is not None and name not in r:142 raise SecurityException('unsafe attributed %r accessed' % name)144 return rv143 return getattr(obj, name)144 return Undefined145146 def call_function(self, f, args, kwargs, dyn_args, dyn_kwargs):147 """
31 unmodified lines
modified:jinja/parser.py+1 added
24 unmodified lines
25end_of_if = lambda p, t, d: t == 'name' and d == 'endif'26end_of_filter = lambda p, t, d: t == 'name' and d == 'endfilter'27end_of_macro = lambda p, t, d: t == 'name' and d == 'endmacro'28end_of_block_tag = lambda p, t, d: t == 'name' and d == 'endblock'29end_of_raw = lambda p, t, d: t == 'name' and d == 'endraw'303132class Parser(object):33 """
319 unmodified lines
added:www/layout/base.html+32 added
added:www/layout/base.tmpl+54 added
1<% set navigation = [2 ('index', 'Index'),3 ('faq', 'FAQ'),4 ('documentation', 'Documentation'),5 ('download', 'Download')6] %>7<% block code %><% endblock %>8<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Frameset//EN"9 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">10<html xmlns="http://www.w3.org/1999/xhtml">11 <head>12 <title><% block title %>Untitled<% endblock %> | Jinja Template Engine</title>13 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />14 <link rel="stylesheet" href="<%= root %>static/style.css" type="text/css" />15 <link rel="stylesheet" href="<%= root %>static/print.css" type="text/css" media="print" />16 <link rel="stylesheet" href="<%= root %>static/pygments.css" type="text/css" />17 </head>18 <body>19 <div id="header">20 <h1>Jinja</h1>21 </div>22 <ul id="navigation">23 <% for id, caption in navigation %>24 <% if id == file_id or id.startswith(file_id + '/') %>25 <li class="active"><%= caption|escape %></li>26 <% else %>27 <li><a href="<%= root %><%= id|escape %>.html"><%= caption|escape %></a></li>28 <% endif %>29 <% endfor %>30 </ul>31 <% if trace %>32 <div id="trace">33 <% for href, caption in trace %>34 <% if loop.last %>35 <%= caption %>36 <% else %>37 <a href="<%= href|escape %>"><%= caption %></a> &raquo;38 <% endif %>39 <% endfor %>40 </div>41 <% endif %>42 <div id="content">43 <div id="contentwrapper">44 <% block content %><% endblock %>45 </div>46 <p id="meta">47 <a href="<%= root + file_id + '.tmpl' %>">show template source</a>48 </p>49 </div>50 <div id="footer">51 &copy; Copyright 2007 by the Pocoo Team.52 </div>53 </body>54</html>
added:www/static/jinjabanner.pngbinary

A binary file, added.

added:www/static/jinjalogo.pngbinary

A binary file, added.

added:www/static/pygments.css+58 added
added:www/static/style.css+137 added
1/**2 * Jinja Webpage Design3 */45body {6 background-color: #333;7 margin: 0;8 padding: 0;9 font-family: 'Georgia', serif;10 font-size: 15px;11 color: #111;12}1314p, li, dd, dt, blockquote {15 color: #333;16}1718p {19 line-height: 150%;20 margin-bottom: 0;21 margin-top: 10px;22 text-align: justify;23}2425hr {26 border-top: 1px solid #ccc;27 border-bottom: 0;28 border-right: 0;29 border-left: 0;30 margin-bottom: 10px;31 margin-top: 20px;32}3334a {35 color: #b41717;36}3738a:hover {39 color: #444;40}4142pre {43 background-color: #f9f9f9;44 border-top: 1px solid #ccc;45 border-bottom: 1px solid #ccc;46 padding: 5px;47 font-size: 13px;48 font-family: 'Bitstream Vera Sans Mono', 'Monaco', monospace;49}5051#content {52 background-color: white;53 background-image: url(watermark.png);54 padding: 10px;55 margin: 25px 25px 0 25px;56 border: 4px solid #ddd;57 border-bottom: none;58}5960#footer {61 margin: 0 25px 25px 25px;62 border-bottom: 4px solid #ddd;63 background-color: #fff;64 text-align: right;65 padding: 0 10px 5px 0;66}6768#contentwrapper {69 max-width: 700px;70 padding: 0 10px 0 20px;71}7273#header {74 height: 80px;75 background-color: #eee;76 background-image: url(jinjabanner.png);77 background-repeat: no-repeat;78 border-bottom: 4px solid #ccc;79}8081#header h1 {82 display: none83}8485#navigation {86 background-color: #fff;87 border: 1px solid #ccc;88 border-right: none;89 margin: 50px 29px 10px 10px;90 padding: 0;91 float: right;92 list-style: none;93 font-weight: bold;94}9596#navigation li a {97 display: block;98 text-decoration: none;99 padding: 5px 10px 5px 10px;100 color: #333;101}102103#navigation li a:hover {104 color: #fff;105 background-color: #444;106}107108#navigation li.active {109 padding: 5px 10px 5px 10px;110 background-color: #b41717;111 color: white;112}113114#navigation li a:focus {115 outline: none;116 background-color: #222;117 color: #fff;118}119120#contentwrapper h1 {121 color: #b41717;122 font-size: 26px;123 margin: 20px 0 0 -5px;124}125126#contentwrapper h2 {127 color: #444;128 font-size: 20px;129 margin: 20px 0 0 0;130}131132#meta {133 clear: both;134 text-align: right;135 color: #888;136 font-size: 13px;137}
added:www/static/watermark.pngbinary

A binary file, added.

added:www/documentation.html+36 added
added:www/documentation.tmpl+8 added
1<% extends 'layout/base.tmpl' %>2<% block title %>Documentation<% endblock %>3<% block content %>4 <h1>Documentation</h1>5 <p>6 You can browse the documentation either online or download it:7 </p>8<% endblock %>
added:www/download.html+52 added
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Frameset//EN"2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">3<html xmlns="http://www.w3.org/1999/xhtml">4 <head>5 <title>Download | Jinja Template Engine</title>6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />7 <link rel="stylesheet" href="./static/style.css" type="text/css" />8 <link rel="stylesheet" href="./static/print.css" type="text/css" media="print" />9 <link rel="stylesheet" href="./static/pygments.css" type="text/css" />10 </head>11 <body>12 <div id="header">13 <h1>Jinja</h1>14 </div>15 <ul id="navigation">16 <li><a href="./index.html">Index</a></li>17 <li><a href="./faq.html">FAQ</a></li>18 <li><a href="./documentation.html">Documentation</a></li>19 <li class="active">Download</li>20 </ul>21 <div id="content">22 <div id="contentwrapper">23 <h1>Download</h1>24 <p>25 If you want to install the release with26 <a href="http://peak.telecommunity.com/DevCenter/EasyInstall">easy_install</a>,27 you can do it using this command:28 </p>29 <pre>easy_install Pygments</pre>30 <p>31 You can also get the development source from subversion using this command:32 </p>33 <pre>svn co http://trac.pocoo.org/repos/jinja/trunk jinja</pre>34 <p>35 Installing the current subversion trunk as a Python egg is done with:36 </p>37 <pre>easy_install Jinja==dev</pre>38 <p>39 Development takes place at the <a href="http://trac.pocoo.org/">Pocoo trac</a>,40 you can browse the source online41 <a href="http://trac.pocoo.org/browser/jinja/trunk">here</a>.42 </p>43 </div>44 <p id="meta">45 <a href="./download.tmpl">show template source</a>46 </p>47 </div>48 <div id="footer">49 &copy; Copyright 2007 by the Pocoo Team.50 </div>51 </body>52</html>
added:www/download.tmpl+24 added
1<% extends 'layout/base.tmpl' %>2<% block title %>Download<% endblock %>3<% block content %>4 <h1>Download</h1>5 <p>6 If you want to install the release with7 <a href="http://peak.telecommunity.com/DevCenter/EasyInstall">easy_install</a>,8 you can do it using this command:9 </p>10 <pre>easy_install Pygments</pre>11 <p>12 You can also get the development source from subversion using this command:13 </p>14 <pre>svn co http://trac.pocoo.org/repos/jinja/trunk jinja</pre>15 <p>16 Installing the current subversion trunk as a Python egg is done with:17 </p>18 <pre>easy_install Jinja==dev</pre>19 <p>20 Development takes place at the <a href="http://trac.pocoo.org/">Pocoo trac</a>,21 you can browse the source online22 <a href="http://trac.pocoo.org/browser/jinja/trunk">here</a>.23 </p>24<% endblock %>
added:www/faq.html+72 added
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Frameset//EN"2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">3<html xmlns="http://www.w3.org/1999/xhtml">4 <head>5 <title>FAQ | Jinja Template Engine</title>6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />7 <link rel="stylesheet" href="./static/style.css" type="text/css" />8 <link rel="stylesheet" href="./static/print.css" type="text/css" media="print" />9 <link rel="stylesheet" href="./static/pygments.css" type="text/css" />10 </head>11 <body>12 <div id="header">13 <h1>Jinja</h1>14 </div>15 <ul id="navigation">16 <li><a href="./index.html">Index</a></li>17 <li class="active">FAQ</li>18 <li><a href="./documentation.html">Documentation</a></li>19 <li><a href="./download.html">Download</a></li>20 </ul>21 <div id="content">22 <div id="contentwrapper">23 <h1>Frequently Asked Questions</h1>24 <p>25 Here a list of frequently asked questions.26 </p>27 <h2>Why the Name?</h2>28 <p>29 The name Jinja was chosen because it's the name of a Japanese temple and30 temple and template share a similar pronunciation.31 </p>32 <h2>How fast is it?</h2>33 <p>34 I really hate benchmarks especially since they don't reflect much. The35 performance of a template depends on many factors and you would have to36 benchmark different engines in differen situations. However Jinja isn't37 slow. The benchmarks from the testsuite show that Jinja is about twice38 as fast as Django templates and about three times as slow as39 <a href="http://www.makotemplates.org/">mako</a>. That's not bad for a40 sandboxed template engine that has to sanitize template input on the fly.41 If you really need the best performance of a template engine consider42 using mako.43 </p>44 <h2>What happened to Jinja &lt; 1?</h2>45 <p>46 Before Jinja 1 there was a template engine too with the same name. Beside47 the name and the same maintainer those two projects don't share a single48 line of code. If you have an application using Jinja &lt; 1 you should try49 to make it Jinja 1 compatible. If that's not possible, the old project is50 still available as 51 <a href="http://trac.pocoo.org/repos/jinja/branches/0.9-maint/">0.9-maint</a>52 in the Jinja subversion repository.53 </p>54 <h2>Why should I use Jinja?</h2>55 <p>56 There are dozens of template engines for Python, many of them try to57 achieve different things. If you are looking for a XML based template58 engine have a look at <a href="http://genshi.edgewall.org/">genshi</a>,59 if you want a bleezing fast template engine with the full range of60 python constructs have a look at mako. If you want sandboxed templates61 you probably want to check out Jinja.62 </p>63 </div>64 <p id="meta">65 <a href="./faq.tmpl">show template source</a>66 </p>67 </div>68 <div id="footer">69 &copy; Copyright 2007 by the Pocoo Team.70 </div>71 </body>72</html>
added:www/faq.tmpl+44 added
1<% extends 'layout/base.tmpl' %>2<% block title %>FAQ<% endblock %>3<% block content %>4 <h1>Frequently Asked Questions</h1>5 <p>6 Here a list of frequently asked questions.7 </p>8 <h2>Why the Name?</h2>9 <p>10 The name Jinja was chosen because it's the name of a Japanese temple and11 temple and template share a similar pronunciation.12 </p>13 <h2>How fast is it?</h2>14 <p>15 I really hate benchmarks especially since they don't reflect much. The16 performance of a template depends on many factors and you would have to17 benchmark different engines in differen situations. However Jinja isn't18 slow. The benchmarks from the testsuite show that Jinja is about twice19 as fast as Django templates and about three times as slow as20 <a href="http://www.makotemplates.org/">mako</a>. That's not bad for a21 sandboxed template engine that has to sanitize template input on the fly.22 If you really need the best performance of a template engine consider23 using mako.24 </p>25 <h2>What happened to Jinja &lt; 1?</h2>26 <p>27 Before Jinja 1 there was a template engine too with the same name. Beside28 the name and the same maintainer those two projects don't share a single29 line of code. If you have an application using Jinja &lt; 1 you should try30 to make it Jinja 1 compatible. If that's not possible, the old project is31 still available as 32 <a href="http://trac.pocoo.org/repos/jinja/branches/0.9-maint/">0.9-maint</a>33 in the Jinja subversion repository.34 </p>35 <h2>Why should I use Jinja?</h2>36 <p>37 There are dozens of template engines for Python, many of them try to38 achieve different things. If you are looking for a XML based template39 engine have a look at <a href="http://genshi.edgewall.org/">genshi</a>,40 if you want a bleezing fast template engine with the full range of41 python constructs have a look at mako. If you want sandboxed templates42 you probably want to check out Jinja.43 </p>44<% endblock %>
added:www/generate.py+46 added
1#!/usr/bin/env python2"""3 jinja webpage generator4 ~~~~~~~~~~~~~~~~~~~~~~~5"""6import os7from codecs import open8from jinja import Environment, FileSystemLoader9from jinja.filters import stringfilter10from pygments import highlight11from pygments.lexers import get_lexer_by_name12from pygments.formatters import HtmlFormatter131415formatter = HtmlFormatter(cssclass='syntax', encoding=None, style='pastie')1617env = Environment('<%', '%>', '<%=', '%>', loader=FileSystemLoader('.'), trim_blocks=True)18env.filters['pygmentize'] = stringfilter(lambda v, l:19 highlight(v.strip(), get_lexer_by_name(l), formatter))202122def get_files(folder):23 for fn in os.listdir(folder):24 fn = os.path.join(folder, fn)25 if os.path.isdir(fn):26 for item in get_files(fn):27 yield item28 elif fn.endswith('.tmpl'):29 yield fn303132for filename in get_files('.'):33 root = './' + ''.join(['../' for _ in os.path.dirname(filename).34 split(os.path.sep)[1:]])3536 t = env.get_template(filename)37 f = open(filename[:-5] + '.html', 'w', 'utf-8')38 f.write(t.render(39 file_id=filename[2:-5],40 root=root41 ))42 f.close()4344f = file('static/pygments.css', 'w')45f.write(formatter.get_style_defs('.syntax'))46f.close()
added:www/index.html+92 added
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Frameset//EN"2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">3<html xmlns="http://www.w3.org/1999/xhtml">4 <head>5 <title>Index | Jinja Template Engine</title>6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />7 <link rel="stylesheet" href="./static/style.css" type="text/css" />8 <link rel="stylesheet" href="./static/print.css" type="text/css" media="print" />9 <link rel="stylesheet" href="./static/pygments.css" type="text/css" />10 </head>11 <body>12 <div id="header">13 <h1>Jinja</h1>14 </div>15 <ul id="navigation">16 <li class="active">Index</li>17 <li><a href="./faq.html">FAQ</a></li>18 <li><a href="./documentation.html">Documentation</a></li>19 <li><a href="./download.html">Download</a></li>20 </ul>21 <div id="content">22 <div id="contentwrapper">23 <h1>Jinja Templates</h1>24 <p>25 Jinja is a26 <a href="http://en.wikipedia.org/wiki/Sandbox_%28computer_security%29">sandboxed</a>27 template engine written in pure <a href="http://www.python.org/">Python</a>. It28 provides a <a href="http://www.djangoproject.com/">Django</a>-like non-XML syntax29 and compiles templates into executable python code. It's basically a combination30 of Django templates and python code.31 </p>32 <h2>Nutshell</h2>33 <div class="syntax"><pre><span class="cp">{%</span> <span class="k">extends</span> <span class="s1">&#39;base.html&#39;</span> <span class="cp">%}</span>34<span class="cp">{%</span> <span class="k">block</span> <span class="nv">title</span> <span class="cp">%}</span>Memberlist<span class="cp">{%</span> <span class="k">endblock</span> <span class="cp">%}</span>35<span class="cp">{%</span> <span class="k">block</span> <span class="nv">content</span> <span class="cp">%}</span>36 <span class="nt">&lt;ul&gt;</span>37 <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>38 <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">user.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">user.username</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="nt">&lt;/a&gt;&lt;/li&gt;</span>39 <span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>40 <span class="nt">&lt;/ul&gt;</span>41<span class="cp">{%</span> <span class="k">endblock</span> <span class="cp">%}</span>42</pre></div>43 <h2>Philosphy</h2>44 <p>45 Application logic is for the controller but don't try to make the live for the46 template designer too hard by giving him too less functionality.47 </p>48 <h2>Features</h2>49 <ul>50 <li><strong>Simple API</strong>. For basic usage just one function is needed:51<div class="syntax"><pre><span class="k">from</span> <span class="nn">jinja</span> <span class="k">import</span> <span class="n">from_string</span>52<span class="k">print</span> <span class="n">from_string</span><span class="p">(</span><span class="s">&#39;Hello {{ data }}!&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="s">&#39;World&#39;</span><span class="p">)</span>53</pre></div>54</li>55 <li><strong>Sandboxed</strong>. The whole engine is completely sandboxed. A56 template designer won't be able to modify application data or execute57 dangerous code.</li>58 <li><strong>Python expressions</strong>. You can use nearly every python59 expression. Not supported are the binary operators and list comprehensions /60 generator expressions.</li>61 <li><strong>Inheritance</strong>. Jinja uses the same concept for inheritance62 Django uses. It's very powerful and easy to understand.</li>63 <li><strong>Macros</strong>. Jinja provides so called macros that allow you to64 put often used template snippets into callable blocks:65<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="o">,</span> <span class="nv">text</span> <span class="cp">%}</span>66 <span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;dialog&quot;</span><span class="nt">&gt;</span>67 <span class="nt">&lt;h2</span> <span class="na">class=</span><span class="s">&quot;title&quot;</span><span class="nt">&gt;</span><span class="cp">{{</span> <span class="nv">title</span> <span class="cp">}}</span><span class="nt">&lt;/h2&gt;</span>68 <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="cp">}}</span><span class="nt">&lt;/div&gt;</span>69 <span class="nt">&lt;/div&gt;</span>70<span class="cp">{%</span> <span class="k">endmacro</span> <span class="cp">%}</span>71</pre></div>72You can then use this block by calling it:73<div class="syntax"><pre><span class="cp">{{</span> <span class="nv">dialog</span><span class="o">(</span><span class="s1">&#39;Notification&#39;</span><span class="o">,</span> <span class="s1">&#39;Here the text for the macro.&#39;</span><span class="o">)</span> <span class="cp">}}</span>74</pre></div>75</li>76 <li><strong>Designer friendly</strong>. Jinja simplifies many things for a77 template designer. Loops can be used in a recursive way, filters are78 available to format values, loops know about their iteration etc.</li>79 <li><strong>Dynamic Syntax</strong>. You don't like the Django block syntax?80 You can override the syntax elements on environment initialisation. It's81 no problem to use ASP/PHP/Ruby syntax, html comments for blocks etc.</li>82 </ul>83 </div>84 <p id="meta">85 <a href="./index.tmpl">show template source</a>86 </p>87 </div>88 <div id="footer">89 &copy; Copyright 2007 by the Pocoo Team.90 </div>91 </body>92</html>
added:www/index.tmpl+65 added
1<% extends 'layout/base.tmpl' %>2<% block title %>Index<% endblock %>3<% block content %>4 <h1>Jinja Templates</h1>5 <p>6 Jinja is a7 <a href="http://en.wikipedia.org/wiki/Sandbox_%28computer_security%29">sandboxed</a>8 template engine written in pure <a href="http://www.python.org/">Python</a>. It9 provides a <a href="http://www.djangoproject.com/">Django</a>-like non-XML syntax10 and compiles templates into executable python code. It's basically a combination11 of Django templates and python code.12 </p>13 <h2>Nutshell</h2>14 <% filter pygmentize('html+jinja') %>15{% extends 'base.html' %}16{% block title %}Memberlist{% endblock %}17{% block content %}18 <ul>19 {% for user in users %}20 <li><a href="{{ user.url|e }}">{{ user.username|e }}</a></li>21 {% endfor %}22 </ul>23{% endblock %}24<% endfilter %>25 <h2>Philosphy</h2>26 <p>27 Application logic is for the controller but don't try to make the live for the28 template designer too hard by giving him too less functionality.29 </p>30 <h2>Features</h2>31 <ul>32 <li><strong>Simple API</strong>. For basic usage just one function is needed:33<% filter pygmentize('python') %>34from jinja import from_string35print from_string('Hello {{ data }}!').render(data='World')36<% endfilter %></li>37 <li><strong>Sandboxed</strong>. The whole engine is completely sandboxed. A38 template designer won't be able to modify application data or execute39 dangerous code.</li>40 <li><strong>Python expressions</strong>. You can use nearly every python41 expression. Not supported are the binary operators and list comprehensions /42 generator expressions.</li>43 <li><strong>Inheritance</strong>. Jinja uses the same concept for inheritance44 Django uses. It's very powerful and easy to understand.</li>45 <li><strong>Macros</strong>. Jinja provides so called macros that allow you to46 put often used template snippets into callable blocks:47<% filter pygmentize('html+jinja') %>48{% macro dialog title, text %}49 <div class="dialog">50 <h2 class="title">{{ title }}</h2>51 <div class="text">{{ text }}</div>52 </div>53{% endmacro %}54<% endfilter %>You can then use this block by calling it:55<% filter pygmentize('html+jinja') %>56{{ dialog('Notification', 'Here the text for the macro.') }}57<% endfilter %></li>58 <li><strong>Designer friendly</strong>. Jinja simplifies many things for a59 template designer. Loops can be used in a recursive way, filters are60 available to format values, loops know about their iteration etc.</li>61 <li><strong>Dynamic Syntax</strong>. You don't like the Django block syntax?62 You can override the syntax elements on environment initialisation. It's63 no problem to use ASP/PHP/Ruby syntax, html comments for blocks etc.</li>64 </ul>65<% endblock %>