"""
from jinja.filters import FILTERS as DEFAULT_FILTERS
from jinja.tests import TESTS as DEFAULT_TESTS
+from jinja.utils import debug_context
DEFAULT_NAMESPACE = {
- 'range': range
+ 'range': range,
+ 'debug': debug_context
}
# the template body
body_lines = [self.handle_node(n) for n in node]
- print list(node)
# add translation helpers if required
if self.require_translations:
queue.extend(node.getChildNodes())
+def debug_context():
+ """
+ Use this function in templates to get a printed context.
+ Use this only in templates because it touches the stack.
+ """
+ context = sys._getframe(2).f_locals['context']
+ from pprint import pformat
+ return pformat(context.to_dict())
+
+
# python2.4 and lower has a bug regarding joining of broken generators
if sys.hexversion < (2, 5):
def capture_generator(gen):
tmpl = e.loader.load('error.html')
tmpl.render(items=range(10))
-make_server("localhost", 7000, DebuggedApplication(test)).serve_forever()
+make_server("localhost", 7000, DebuggedApplication(test, False)).serve_forever()
<ul>
+<meta http-equiv="Content-Type" content="" />
{% for item in items %}
- {{ item + "this is some strange unicode" }}
+ {{ item + "this will break the application" }}
{% endfor %}
</ul>