mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +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:
parent
eb5ebcc2d0
commit
55f12f8709
13 changed files with 295 additions and 302 deletions
|
@ -311,3 +311,15 @@ class BasicSyntaxTests(SimpleTestCase):
|
|||
"""
|
||||
output = self.engine.render_to_string('basic-syntax38', {"var": {"callable": lambda: "foo bar"}})
|
||||
self.assertEqual(output, 'foo bar')
|
||||
|
||||
@setup({'template': '{% block content %}'})
|
||||
def test_unclosed_block(self):
|
||||
msg = "Unclosed tag 'block'. Looking for one of: endblock."
|
||||
with self.assertRaisesMessage(TemplateSyntaxError, msg):
|
||||
self.engine.render_to_string('template')
|
||||
|
||||
@setup({'template': '{% if a %}'})
|
||||
def test_unclosed_block2(self):
|
||||
msg = "Unclosed tag 'if'. Looking for one of: elif, else, endif."
|
||||
with self.assertRaisesMessage(TemplateSyntaxError, msg):
|
||||
self.engine.render_to_string('template')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue