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.03 kb
de478f6 Armin Ronacher [svn] some small updates to make jinja performing better
authored
1 # -*- coding: utf-8 -*-
5829306 Armin Ronacher moved docstring into setup.py, this fixes #297
authored
2 """
203bfcb Armin Ronacher inheritance uses a less awkward hack for contexts now and subclassing te...
authored
3 Jinja2
4 ~~~~~~
5829306 Armin Ronacher moved docstring into setup.py, this fixes #297
authored
5
203bfcb Armin Ronacher 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.
5829306 Armin Ronacher 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 Armin Ronacher inheritance uses a less awkward hack for contexts now and subclassing te...
authored
20 <li><a href="{{ user.url }}">{{ user.username }}</a></li>
5829306 Armin Ronacher 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
203bfcb Armin Ronacher inheritance uses a less awkward hack for contexts now and subclassing te...
authored
31 For more informations visit the new `jinja2 webpage`_ and `documentation`_.
5829306 Armin Ronacher moved docstring into setup.py, this fixes #297
authored
32
203bfcb Armin Ronacher inheritance uses a less awkward hack for contexts now and subclassing te...
authored
33 The `Jinja2 tip`_ is installable via `easy_install` with ``easy_install
34 Jinja2==dev``.
5829306 Armin Ronacher 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/
203bfcb Armin Ronacher inheritance uses a less awkward hack for contexts now and subclassing te...
authored
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
5829306 Armin Ronacher moved docstring into setup.py, this fixes #297
authored
41 """
0830e25 Armin Ronacher [svn] moved www out of jinja trunk and updated setup.py file
authored
42 import os
d15a4dc Armin Ronacher [svn] updated Jinja setup.py for (hopefully for) win32 compatibility
authored
43 import sys
0830e25 Armin Ronacher [svn] moved www out of jinja trunk and updated setup.py file
authored
44 import ez_setup
45 ez_setup.use_setuptools()
ee2c18e Armin Ronacher [svn] added c implementation of the jinja context class.
authored
46
bd33f11 Armin Ronacher 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 Armin Ronacher [svn] some small updates to make jinja performing better
authored
50
0830e25 Armin Ronacher [svn] moved www out of jinja trunk and updated setup.py file
authored
51
e21ced2 Armin Ronacher [svn] again jinja setup.py update. works now
authored
52 def list_files(path):
53 for fn in os.listdir(path):
54 if fn.startswith('.'):
55 continue
56 fn = os.path.join(path, fn)
57 if os.path.isfile(fn):
58 yield fn
59
60
203bfcb Armin Ronacher inheritance uses a less awkward hack for contexts now and subclassing te...
authored
61 def get_terminal_width():
62 """Return the current terminal dimensions."""
63 try:
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]
69 except:
70 return 80
71
72
bd33f11 Armin Ronacher added C escape and tb_set_next functions
authored
73 class optional_build_ext(build_ext):
74 """This class allows C extension building to fail."""
75
76 def run(self):
77 try:
78 build_ext.run(self)
79 except DistutilsPlatformError:
80 self._unavailable()
81
82 def build_extension(self, ext):
83 try:
84 build_ext.build_extension(self, ext)
85 except CCompilerError, x:
86 self._unavailable()
87
88 def _unavailable(self):
203bfcb Armin Ronacher inheritance uses a less awkward hack for contexts now and subclassing te...
authored
89 width = get_terminal_width()
90 print '*' * width
bd33f11 Armin Ronacher added C escape and tb_set_next functions
authored
91 print """WARNING:
92 An optional C extension could not be compiled, speedups will not be
93 available."""
203bfcb Armin Ronacher inheritance uses a less awkward hack for contexts now and subclassing te...
authored
94 print '*' * width
bd33f11 Armin Ronacher added C escape and tb_set_next functions
authored
95
96
de478f6 Armin Ronacher [svn] some small updates to make jinja performing better
authored
97 setup(
203bfcb Armin Ronacher inheritance uses a less awkward hack for contexts now and subclassing te...
authored
98 name='Jinja2',
4a3038d Armin Ronacher update setup.py so that setup.py develop works
authored
99 version='2.0dev',
015b0c9 Armin Ronacher some documentation changes
authored
100 url='http://jinja.pocoo.org/',
101 license='BSD',
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.',
bd33f11 Armin Ronacher added C escape and tb_set_next functions
authored
106 long_description=__doc__,
e21ced2 Armin Ronacher [svn] again jinja setup.py update. works now
authored
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
015b0c9 Armin Ronacher some documentation changes
authored
109 zip_safe=False,
110 classifiers=[
f59bac2 Armin Ronacher added first code for parser extensions and moved some code in speedups a...
authored
111 'Development Status :: 4 Beta',
de478f6 Armin Ronacher [svn] some small updates to make jinja performing better
authored
112 'Environment :: Web Environment',
113 'Intended Audience :: Developers',
114 'License :: OSI Approved :: BSD License',
115 'Operating System :: OS Independent',
116 'Programming Language :: Python',
8ebf1f9 Armin Ronacher [svn] doc update, setup.py update, added turbogears plugin
authored
117 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
118 'Topic :: Software Development :: Libraries :: Python Modules',
119 'Topic :: Text Processing :: Markup :: HTML'
120 ],
4a3038d Armin Ronacher update setup.py so that setup.py develop works
authored
121 packages=['jinja2'],
015b0c9 Armin Ronacher some documentation changes
authored
122 data_files=[
7ceced5 Armin Ronacher moved concat to utils, fixed a few docstrings, fixed memory leak in _spe...
authored
123 ##('docs', list(list_files('docs/_build/html')))
0830e25 Armin Ronacher [svn] moved www out of jinja trunk and updated setup.py file
authored
124 ],
bd33f11 Armin Ronacher 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 Armin Ronacher fixed setup.py, a type and removed the possibility to use multiple state...
authored
133 extras_require={'i18n': ['Babel>=0.8']},
f59bac2 Armin Ronacher added first code for parser extensions and moved some code in speedups a...
authored
134 entry_points="""
135 [babel.extractors]
7962ce7 Armin Ronacher fixed babel entry point
authored
136 jinja2 = jinja2.ext:babel_extract[i18n]
f59bac2 Armin Ronacher added first code for parser extensions and moved some code in speedups a...
authored
137 """
de478f6 Armin Ronacher [svn] some small updates to make jinja performing better
authored
138 )
Something went wrong with that request. Please try again.