mirror of
https://github.com/django/django.git
synced 2024-12-23 09:36:06 +00:00
Fixed #4267 -- In example code, extract the template tag name correctly in
error messages where Token.split_contents() has failed. Thanks, keisuke.nishida@gmail.com. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5188 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
f9982c5c08
commit
de5f67f17e
@ -717,7 +717,7 @@ object::
|
||||
# split_contents() knows not to split quoted strings.
|
||||
tag_name, format_string = token.split_contents()
|
||||
except ValueError:
|
||||
raise template.TemplateSyntaxError, "%r tag requires a single argument" % token.contents[0]
|
||||
raise template.TemplateSyntaxError, "%r tag requires a single argument" % token.contents.split()[0]
|
||||
if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")):
|
||||
raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name
|
||||
return CurrentTimeNode(format_string[1:-1])
|
||||
@ -846,7 +846,7 @@ Now your tag should begin to look like this::
|
||||
# split_contents() knows not to split quoted strings.
|
||||
tag_name, date_to_be_formatted, format_string = token.split_contents()
|
||||
except ValueError:
|
||||
raise template.TemplateSyntaxError, "%r tag requires exactly two arguments" % token.contents[0]
|
||||
raise template.TemplateSyntaxError, "%r tag requires exactly two arguments" % token.contents.split()[0]
|
||||
if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")):
|
||||
raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name
|
||||
return FormatTimeNode(date_to_be_formatted, format_string[1:-1])
|
||||
@ -1080,7 +1080,7 @@ class, like so::
|
||||
# Splitting by None == splitting by spaces.
|
||||
tag_name, arg = token.contents.split(None, 1)
|
||||
except ValueError:
|
||||
raise template.TemplateSyntaxError, "%r tag requires arguments" % token.contents[0]
|
||||
raise template.TemplateSyntaxError, "%r tag requires arguments" % token.contents.split()[0]
|
||||
m = re.search(r'(.*?) as (\w+)', arg)
|
||||
if not m:
|
||||
raise template.TemplateSyntaxError, "%r tag had invalid arguments" % tag_name
|
||||
|
Loading…
Reference in New Issue
Block a user