diff options
author | Markus Unterwaditzer <markus@unterwaditzer.net> | 2015-03-22 14:22:40 +0100 |
---|---|---|
committer | Markus Unterwaditzer <markus@unterwaditzer.net> | 2015-03-22 14:22:52 +0100 |
commit | 599c1360bc42ae9ca21525299d92c6cd9ba887b5 (patch) | |
tree | 6b04568054459d1d3887ded6f0a8ba3340571ba5 /scripts | |
parent | 1c5f1e8d85bdb2e0157685a61d3c9dda41108a7c (diff) | |
download | jinja2-599c1360bc42ae9ca21525299d92c6cd9ba887b5.tar.gz |
Fix doctests
Fix #427
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/jinja2-debug.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/jinja2-debug.py b/scripts/jinja2-debug.py new file mode 100755 index 0000000..d052adc --- /dev/null +++ b/scripts/jinja2-debug.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" + Jinja2 Debug Interface + ~~~~~~~~~~~~~~~~~~~~~~ + + Helper script for internal Jinja2 debugging. Requires Werkzeug. + + :copyright: Copyright 2010 by Armin Ronacher. + :license: BSD. +""" +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() |