Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 70 lines (56 sloc) 2.272 kb
92f572f @mitsuhiko [svn] added new jinja trunk
authored
1 # -*- coding: utf-8 -*-
2 """
07bc684 @mitsuhiko a clean restart
authored
3 jinja2
4 ~~~~~~
ae16fd0 @mitsuhiko [svn] reworked the jinja escaping system, removed getattr concatenating ...
authored
5
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing te...
authored
6 Jinja2 is a template engine written in pure Python. It provides a
7 Django inspired non-XML syntax but supports inline expressions and
8 an optional sandboxed environment.
ae16fd0 @mitsuhiko [svn] reworked the jinja escaping system, removed getattr concatenating ...
authored
9
10 Nutshell
11 --------
12
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing te...
authored
13 Here a small example of a Jinja2 template::
ae16fd0 @mitsuhiko [svn] reworked the jinja escaping system, removed getattr concatenating ...
authored
14
15 {% extends 'base.html' %}
16 {% block title %}Memberlist{% endblock %}
17 {% block content %}
18 <ul>
19 {% for user in users %}
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing te...
authored
20 <li><a href="{{ user.url }}">{{ user.username }}</a></li>
ae16fd0 @mitsuhiko [svn] reworked the jinja escaping system, removed getattr concatenating ...
authored
21 {% endfor %}
22 </ul>
23 {% endblock %}
24
25
55494e4 @mitsuhiko It's a new year
authored
26 :copyright: (c) 2010 by the Jinja Team.
92f572f @mitsuhiko [svn] added new jinja trunk
authored
27 :license: BSD, see LICENSE for more details.
28 """
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing te...
authored
29 __docformat__ = 'restructuredtext en'
9b1de00 @mitsuhiko master is 2.7-dev
authored
30 __version__ = '2.7-dev'
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing te...
authored
31
32 # high level interface
33 from jinja2.environment import Environment, Template
34
35 # loaders
9a82205 @mitsuhiko improved undefined behavior
authored
36 from jinja2.loaders import BaseLoader, FileSystemLoader, PackageLoader, \
64b08a0 @mitsuhiko added a :class:`ModuleLoader` that can load templates from
authored
37 DictLoader, FunctionLoader, PrefixLoader, ChoiceLoader, \
38 ModuleLoader
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing te...
authored
39
a816bf4 @mitsuhiko Improved bbcache and documented it.
authored
40 # bytecode caches
aa1d17d @mitsuhiko Fixed bytecode cache and added support for memcached (tests still missin...
authored
41 from jinja2.bccache import BytecodeCache, FileSystemBytecodeCache, \
42 MemcachedBytecodeCache
a816bf4 @mitsuhiko Improved bbcache and documented it.
authored
43
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing te...
authored
44 # undefined types
c63243e @mitsuhiko added sandbox and exchageable undefined objects
authored
45 from jinja2.runtime import Undefined, DebugUndefined, StrictUndefined
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing te...
authored
46
d134231 @mitsuhiko autoescaping is separate from finalize now and Markup is completely igno...
authored
47 # exceptions
48 from jinja2.exceptions import TemplateError, UndefinedError, \
31bbd9e @mitsuhiko include tags are now able to select between multiple templates
authored
49 TemplateNotFound, TemplatesNotFound, TemplateSyntaxError, \
50 TemplateAssertionError
d134231 @mitsuhiko autoescaping is separate from finalize now and Markup is completely igno...
authored
51
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing te...
authored
52 # decorators and public utilities
8346bd7 @mitsuhiko Biggest change to Jinja since the 1.x migration: added evaluation contex...
authored
53 from jinja2.filters import environmentfilter, contextfilter, \
54 evalcontextfilter
187bde1 @mitsuhiko added cache_clear function
authored
55 from jinja2.utils import Markup, escape, clear_caches, \
8346bd7 @mitsuhiko Biggest change to Jinja since the 1.x migration: added evaluation contex...
authored
56 environmentfunction, evalcontextfunction, contextfunction, \
57 is_undefined
7259c76 @mitsuhiko moved caching from loaders to environment and added environment overlays
authored
58
59 __all__ = [
60 'Environment', 'Template', 'BaseLoader', 'FileSystemLoader',
61 'PackageLoader', 'DictLoader', 'FunctionLoader', 'PrefixLoader',
ccae055 @mitsuhiko Various cleanups and added custom cycler.
authored
62 'ChoiceLoader', 'BytecodeCache', 'FileSystemBytecodeCache',
63 'MemcachedBytecodeCache', 'Undefined', 'DebugUndefined',
64 'StrictUndefined', 'TemplateError', 'UndefinedError', 'TemplateNotFound',
31bbd9e @mitsuhiko include tags are now able to select between multiple templates
authored
65 'TemplatesNotFound', 'TemplateSyntaxError', 'TemplateAssertionError',
64b08a0 @mitsuhiko added a :class:`ModuleLoader` that can load templates from
authored
66 'ModuleLoader', 'environmentfilter', 'contextfilter', 'Markup', 'escape',
8346bd7 @mitsuhiko Biggest change to Jinja since the 1.x migration: added evaluation contex...
authored
67 'environmentfunction', 'contextfunction', 'clear_caches', 'is_undefined',
68 'evalcontextfilter', 'evalcontextfunction'
7259c76 @mitsuhiko moved caching from loaders to environment and added environment overlays
authored
69 ]
Something went wrong with that request. Please try again.