mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Cleaned up the template debug implementation.
This patch does three major things: * Merges the django.template.debug implementation into django.template.base. * Simplifies the debug implementation. The old implementation copied debug information to every token and node. The django_template_source attribute was set in multiple places, some quite hacky, like django.template.defaulttags.ForNode. Debug information is now annotated in two high-level places: * Template.compile_nodelist for errors during parsing * Node.render_annotated for errors during rendering These were chosen because they have access to the template and context as well as to all exceptions that happen during either the parse or render phase. * Moves the contextual line traceback information creation from django.views.debug into django.template.base.Template. The debug views now only deal with the presentation of the debug information.
This commit is contained in:
committed by
Tim Graham
parent
eb5ebcc2d0
commit
55f12f8709
@@ -52,23 +52,11 @@ class DeprecatedRenderToStringTest(SimpleTestCase):
|
||||
|
||||
class LoaderTests(SimpleTestCase):
|
||||
|
||||
def test_debug_nodelist_name(self):
|
||||
engine = Engine(dirs=[TEMPLATE_DIR], debug=True)
|
||||
template_name = 'index.html'
|
||||
template = engine.get_template(template_name)
|
||||
name = template.nodelist[0].source[0].name
|
||||
self.assertTrue(name.endswith(template_name))
|
||||
|
||||
def test_origin(self):
|
||||
engine = Engine(dirs=[TEMPLATE_DIR], debug=True)
|
||||
template = engine.get_template('index.html')
|
||||
self.assertEqual(template.origin.loadname, 'index.html')
|
||||
|
||||
def test_origin_debug_false(self):
|
||||
engine = Engine(dirs=[TEMPLATE_DIR], debug=False)
|
||||
template = engine.get_template('index.html')
|
||||
self.assertEqual(template.origin, None)
|
||||
|
||||
def test_loader_priority(self):
|
||||
"""
|
||||
#21460 -- Check that the order of template loader works.
|
||||
|
||||
Reference in New Issue
Block a user