Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #4098 -- fixed a syntax error when reporting errors in "with" t…

…emplate

tag. Thanks cephelo@gmail.com.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5048 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 539a7ab993b000c6417018776d62de523eda7787 1 parent e19ccda
Malcolm Tredinnick authored April 21, 2007
4  django/template/defaulttags.py
@@ -990,7 +990,7 @@ def do_with(parser, token):
990 990
     """
991 991
     Add a value to the context (inside of this block) for caching and easy
992 992
     access.
993  
-    
  993
+
994 994
     For example::
995 995
 
996 996
         {% with person.some_sql_method as total %}
@@ -999,7 +999,7 @@ def do_with(parser, token):
999 999
     """
1000 1000
     bits = list(token.split_contents())
1001 1001
     if len(bits) != 4 or bits[2] != "as":
1002  
-        raise TemplateSyntaxError, "%r expected format is 'value as name'" % tagname
  1002
+        raise TemplateSyntaxError, "%r expected format is 'value as name'" % bits[0]
1003 1003
     var = parser.compile_filter(bits[1])
1004 1004
     name = bits[3]
1005 1005
     nodelist = parser.parse(('endwith',))
3  tests/regressiontests/templates/tests.py
@@ -654,6 +654,9 @@ def test_templates(self):
654 654
             'with01': ('{% with dict.key as key %}{{ key }}{% endwith %}', {'dict': {'key':50}}, '50'),
655 655
             'with02': ('{{ key }}{% with dict.key as key %}{{ key }}-{{ dict.key }}-{{ key }}{% endwith %}{{ key }}', {'dict': {'key':50}}, ('50-50-50', 'INVALID50-50-50INVALID')),
656 656
 
  657
+            'with-error01': ('{% with dict.key xx key %}{{ key }}{% endwith %}', {'dict': {'key':50}}, template.TemplateSyntaxError),
  658
+            'with-error02': ('{% with dict.key as %}{{ key }}{% endwith %}', {'dict': {'key':50}}, template.TemplateSyntaxError),
  659
+
657 660
             ### NOW TAG ########################################################
658 661
             # Simple case
659 662
             'now01' : ('{% now "j n Y"%}', {}, str(datetime.now().day) + ' ' + str(datetime.now().month) + ' ' + str(datetime.now().year)),

0 notes on commit 539a7ab

Please sign in to comment.
Something went wrong with that request. Please try again.