blob: 13350db6a05a19388e18c55328975afe1d1554ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Jinja Debug Interface
~~~~~~~~~~~~~~~~~~~~~
Helper script for internal Jinja debugging. Requires Werkzeug.
:copyright: Copyright 2010 by Armin Ronacher.
:license: BSD.
"""
from __future__ import print_function
import sys
import jinja2
from werkzeug import script
env = jinja2.Environment(extensions=['jinja2.ext.i18n', 'jinja2.ext.do',
'jinja2.ext.loopcontrols',
'jinja2.ext.with_',
'jinja2.ext.autoescape'],
autoescape=True)
def shell_init_func():
def _compile(x):
print(env.compile(x, raw=True))
result = {
'e': env,
'c': _compile,
't': env.from_string,
'p': env.parse
}
for key in jinja2.__all__:
result[key] = getattr(jinja2, key)
return result
def action_compile():
print(env.compile(sys.stdin.read(), raw=True))
action_shell = script.make_shell(shell_init_func)
if __name__ == '__main__':
script.run()
|