From de5f67f17e9ab3f6a860ad93d6c1fbc2c0c7f3b2 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Fri, 11 May 2007 08:50:54 +0000 Subject: [PATCH] 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 --- docs/templates_python.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/templates_python.txt b/docs/templates_python.txt index 853707f58c3..08a287f572d 100644 --- a/docs/templates_python.txt +++ b/docs/templates_python.txt @@ -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