1 # -*- coding: utf-8 -*-
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.
13 Here a small example of a Jinja template::
15 {% extends 'base.html' %}
16 {% block title %}Memberlist{% endblock %}
19 {% for user in users %}
20 <li><a href="{{ user.url }}">{{ user.username }}</a></li>
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.
31 For more informations visit the new `jinja2 webpage`_ and `documentation`_.
33 The `Jinja2 tip`_ is installable via `easy_install` with ``easy_install
36 .. _sandboxed: http://en.wikipedia.org/wiki/Sandbox_(computer_security)
37 .. _Django: http://www.djangoproject.com/
38 .. _jinja webpage: http://jinja2.pocoo.org/
39 .. _documentation: http://jinja2.pocoo.org/documentation/index.html
40 .. _Jinja tip: http://dev.pocoo.org/hg/jinja2-main/archive/tip.tar.gz#egg=Jinja2-dev
45 ez_setup.use_setuptools()
47 from setuptools import setup, Extension, Feature
48 from distutils.command.build_ext import build_ext
49 from distutils.errors import CCompilerError, DistutilsPlatformError
53 for fn in os.listdir(path):
54 if fn.startswith('.'):
56 fn = os.path.join(path, fn)
57 if os.path.isfile(fn):
61 def get_terminal_width():
62 """Return the current terminal dimensions."""
64 from struct import pack, unpack
65 from fcntl import ioctl
66 from termios import TIOCGWINSZ
67 s = pack('HHHH', 0, 0, 0, 0)
68 return unpack('HHHH', ioctl(sys.stdout.fileno(), TIOCGWINSZ, s))[1]
73 class optional_build_ext(build_ext):
74 """This class allows C extension building to fail."""
79 except DistutilsPlatformError:
82 def build_extension(self, ext):
84 build_ext.build_extension(self, ext)
85 except CCompilerError, x:
88 def _unavailable(self):
89 width = get_terminal_width()
92 An optional C extension could not be compiled, speedups will not be
100 url='http://jinja.pocoo.org/',
102 author='Armin Ronacher',
103 author_email='armin.ronacher@active-4.com',
104 description='A small but fast and easy to use stand-alone template '
105 'engine written in pure python.',
106 long_description=__doc__,
107 # jinja is egg safe. But because we distribute the documentation
108 # in form of html and txt files it's a better idea to extract the files
111 'Development Status :: 4 Beta',
112 'Environment :: Web Environment',
113 'Intended Audience :: Developers',
114 'License :: OSI Approved :: BSD License',
115 'Operating System :: OS Independent',
116 'Programming Language :: Python',
117 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
118 'Topic :: Software Development :: Libraries :: Python Modules',
119 'Topic :: Text Processing :: Markup :: HTML'
123 ##('docs', list(list_files('docs/_build/html')))
126 'speedups': Feature("optional C speed-enhancements",
129 Extension('jinja2._speedups', ['jinja2/_speedups.c'])
133 extras_require={'i18n': ['Babel>=0.8']},
136 jinja2 = jinja.ext:babel_extract[i18n]