Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 139 lines (117 sloc) 4.144 kb
de478f6 @mitsuhiko [svn] some small updates to make jinja performing better
authored
1 # -*- coding: utf-8 -*-
5829306 @mitsuhiko moved docstring into setup.py, this fixes #297
authored
2 """
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing…
authored
3 Jinja2
4 ~~~~~~
5829306 @mitsuhiko moved docstring into setup.py, this fixes #297
authored
5
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing…
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.
5829306 @mitsuhiko moved docstring into setup.py, this fixes #297
authored
9
10 Nutshell
11 --------
12
13 Here a small example of a Jinja template::
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…
authored
20 <li><a href="{{ user.url }}">{{ user.username }}</a></li>
5829306 @mitsuhiko moved docstring into setup.py, this fixes #297
authored
21 {% endfor %}
22 </ul>
23 {% endblock %}
24
25 Philosophy
26 ----------
27
28 Application logic is for the controller but don't try to make the life
29 for the template designer too hard by giving him too few functionality.
30
f4e1fb4 @mitsuhiko small fix for Python 2.4
authored
31 For more informations visit the new `Jinja2 webpage`_ and `documentation`_.
5829306 @mitsuhiko moved docstring into setup.py, this fixes #297
authored
32
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing…
authored
33 The `Jinja2 tip`_ is installable via `easy_install` with ``easy_install
34 Jinja2==dev``.
5829306 @mitsuhiko moved docstring into setup.py, this fixes #297
authored
35
36 .. _sandboxed: http://en.wikipedia.org/wiki/Sandbox_(computer_security)
37 .. _Django: http://www.djangoproject.com/
f4e1fb4 @mitsuhiko small fix for Python 2.4
authored
38 .. _Jinja2 webpage: http://jinja.pocoo.org/
1a12c8a @mitsuhiko release trying #3: fixed typos in description :)
authored
39 .. _documentation: http://jinja.pocoo.org/2/documentation/
40 .. _Jinja2 tip: http://dev.pocoo.org/hg/jinja2-main/archive/tip.tar.gz#egg=Jinja2-dev
5829306 @mitsuhiko moved docstring into setup.py, this fixes #297
authored
41 """
0830e25 @mitsuhiko [svn] moved www out of jinja trunk and updated setup.py file
authored
42 import os
d15a4dc @mitsuhiko [svn] updated Jinja setup.py for (hopefully for) win32 compatibility
authored
43 import sys
0830e25 @mitsuhiko [svn] moved www out of jinja trunk and updated setup.py file
authored
44 import ez_setup
45 ez_setup.use_setuptools()
ee2c18e @mitsuhiko [svn] added c implementation of the jinja context class.
authored
46
bd33f11 @mitsuhiko added C escape and tb_set_next functions
authored
47 from setuptools import setup, Extension, Feature
48 from distutils.command.build_ext import build_ext
49 from distutils.errors import CCompilerError, DistutilsPlatformError
de478f6 @mitsuhiko [svn] some small updates to make jinja performing better
authored
50
0830e25 @mitsuhiko [svn] moved www out of jinja trunk and updated setup.py file
authored
51
58f351d @mitsuhiko data files are optional now
authored
52 data_files = []
53 documentation_path = 'docs/_build/html'
54 if os.path.exists(documentation_path):
55 documentation_files = []
56 for fn in os.listdir(documentation_path):
57 if not fn.startswith('.'):
58 fn = os.path.join(documentation_path, fn)
59 if os.path.isfile(fn):
60 documentation_files.append(fn)
61 data_files.append(('docs', documentation_files))
e21ced2 @mitsuhiko [svn] again jinja setup.py update. works now
authored
62
63
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing…
authored
64 def get_terminal_width():
65 """Return the current terminal dimensions."""
66 try:
67 from struct import pack, unpack
68 from fcntl import ioctl
69 from termios import TIOCGWINSZ
70 s = pack('HHHH', 0, 0, 0, 0)
71 return unpack('HHHH', ioctl(sys.stdout.fileno(), TIOCGWINSZ, s))[1]
72 except:
73 return 80
74
75
bd33f11 @mitsuhiko added C escape and tb_set_next functions
authored
76 class optional_build_ext(build_ext):
77 """This class allows C extension building to fail."""
78
79 def run(self):
80 try:
81 build_ext.run(self)
82 except DistutilsPlatformError:
83 self._unavailable()
84
85 def build_extension(self, ext):
86 try:
87 build_ext.build_extension(self, ext)
88 except CCompilerError, x:
89 self._unavailable()
90
91 def _unavailable(self):
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing…
authored
92 width = get_terminal_width()
93 print '*' * width
bd33f11 @mitsuhiko added C escape and tb_set_next functions
authored
94 print """WARNING:
95 An optional C extension could not be compiled, speedups will not be
96 available."""
97
98
de478f6 @mitsuhiko [svn] some small updates to make jinja performing better
authored
99 setup(
203bfcb @mitsuhiko inheritance uses a less awkward hack for contexts now and subclassing…
authored
100 name='Jinja2',
fa5a74f @mitsuhiko updated setup file for Jinja2 rc1
authored
101 version='2.0rc1',
015b0c9 @mitsuhiko some documentation changes
authored
102 url='http://jinja.pocoo.org/',
103 license='BSD',
104 author='Armin Ronacher',
105 author_email='armin.ronacher@active-4.com',
106 description='A small but fast and easy to use stand-alone template '
107 'engine written in pure python.',
bd33f11 @mitsuhiko added C escape and tb_set_next functions
authored
108 long_description=__doc__,
e21ced2 @mitsuhiko [svn] again jinja setup.py update. works now
authored
109 # jinja is egg safe. But because we distribute the documentation
110 # in form of html and txt files it's a better idea to extract the files
015b0c9 @mitsuhiko some documentation changes
authored
111 zip_safe=False,
112 classifiers=[
da5118b @mitsuhiko untagged 2.0rc1 again and fixed classifier
authored
113 'Development Status :: 4 - Beta',
de478f6 @mitsuhiko [svn] some small updates to make jinja performing better
authored
114 'Environment :: Web Environment',
115 'Intended Audience :: Developers',
116 'License :: OSI Approved :: BSD License',
117 'Operating System :: OS Independent',
118 'Programming Language :: Python',
8ebf1f9 @mitsuhiko [svn] doc update, setup.py update, added turbogears plugin
authored
119 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
120 'Topic :: Software Development :: Libraries :: Python Modules',
121 'Topic :: Text Processing :: Markup :: HTML'
122 ],
4a3038d @mitsuhiko update setup.py so that setup.py develop works
authored
123 packages=['jinja2'],
58f351d @mitsuhiko data files are optional now
authored
124 data_files=data_files,
bd33f11 @mitsuhiko added C escape and tb_set_next functions
authored
125 features={
126 'speedups': Feature("optional C speed-enhancements",
127 standard=True,
128 ext_modules=[
129 Extension('jinja2._speedups', ['jinja2/_speedups.c'])
130 ]
131 )
132 },
2b60fe5 @mitsuhiko fixed setup.py, a type and removed the possibility to use multiple st…
authored
133 extras_require={'i18n': ['Babel>=0.8']},
f59bac2 @mitsuhiko added first code for parser extensions and moved some code in speedup…
authored
134 entry_points="""
135 [babel.extractors]
7962ce7 @mitsuhiko fixed babel entry point
authored
136 jinja2 = jinja2.ext:babel_extract[i18n]
f59bac2 @mitsuhiko added first code for parser extensions and moved some code in speedup…
authored
137 """
de478f6 @mitsuhiko [svn] some small updates to make jinja performing better
authored
138 )
Something went wrong with that request. Please try again.