Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 41 lines (31 sloc) 0.93 kb
27069d7 @mitsuhiko fixed a bug in extension handling
authored
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 """
4 Jinja2 Debug Interface
5 ~~~~~~~~~~~~~~~~~~~~~~
6
7 Helper script for internal Jinja2 debugging. Requires Werkzeug.
8
ae8a930 @mitsuhiko The jdebug file should have a 2010 copyright as well.
authored
9 :copyright: Copyright 2010 by Armin Ronacher.
27069d7 @mitsuhiko fixed a bug in extension handling
authored
10 :license: BSD.
11 """
12 import sys
13 import jinja2
14 from werkzeug import script
15
5c047ea @mitsuhiko Environment.lex returns unicode tokens now, even if the input data was a...
authored
16 env = jinja2.Environment(extensions=['jinja2.ext.i18n', 'jinja2.ext.do',
17 'jinja2.ext.loopcontrols'])
27069d7 @mitsuhiko fixed a bug in extension handling
authored
18
19 def shell_init_func():
20 def _compile(x):
21 print env.compile(x, raw=True)
22 result = {
23 'e': env,
24 'c': _compile,
25 't': env.from_string,
26 'p': env.parse
27 }
28 for key in jinja2.__all__:
29 result[key] = getattr(jinja2, key)
30 return result
31
32
33 def action_compile():
34 print env.compile(sys.stdin.read(), raw=True)
35
36 action_shell = script.make_shell(shell_init_func)
37
38
39 if __name__ == '__main__':
40 script.run()
Something went wrong with that request. Please try again.