blob: a250a62ffd8835117754475a1aa1d6866d56957e [file] [log] [blame]
Armin Ronacher27069d72008-05-11 19:48:12 +02001#!/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
9 :copyright: Copyright 2008 by Armin Ronacher.
10 :license: BSD.
11"""
12import sys
13import jinja2
14from werkzeug import script
15
Armin Ronacher5d2733f2008-05-15 23:26:52 +020016env = jinja2.Environment(extensions=['jinja2.ext.i18n', 'jinja2.ext.do'])
Armin Ronacher27069d72008-05-11 19:48:12 +020017
18def shell_init_func():
19 def _compile(x):
20 print env.compile(x, raw=True)
21 result = {
22 'e': env,
23 'c': _compile,
24 't': env.from_string,
25 'p': env.parse
26 }
27 for key in jinja2.__all__:
28 result[key] = getattr(jinja2, key)
29 return result
30
31
32def action_compile():
33 print env.compile(sys.stdin.read(), raw=True)
34
35action_shell = script.make_shell(shell_init_func)
36
37
38if __name__ == '__main__':
39 script.run()