summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorIan Lee <IanLee1521@gmail.com>2015-02-22 11:43:38 -0800
committerTim Graham <timograham@gmail.com>2015-02-23 07:46:00 -0500
commit04c262aea9b398c79e753ae75aa12b1520e99854 (patch)
treeb8868f45c92cc701b07090497dc2c62d3c32fd6e /docs
parentff2e0896a3f7b566c8a0802b2191d30c6070c8f6 (diff)
[1.8.x] Broke long lines in code examples.
The website only renders code blocks at 96 chars, and therefore long code lines get wrapped. Manually breaking the lines prevents the wrapping from occurring. Backport of 00fbd8fd527fd6ee0319361bf194cd51a1ac1bfb from master
Diffstat (limited to 'docs')
-rw-r--r--docs/howto/custom-template-tags.txt24
1 files changed, 18 insertions, 6 deletions
diff --git a/docs/howto/custom-template-tags.txt b/docs/howto/custom-template-tags.txt
index ca21e16549..97ba2a39d3 100644
--- a/docs/howto/custom-template-tags.txt
+++ b/docs/howto/custom-template-tags.txt
@@ -706,9 +706,13 @@ 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.split()[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)
+ raise template.TemplateSyntaxError(
+ "%r tag's argument should be in quotes" % tag_name
+ )
return CurrentTimeNode(format_string[1:-1])
Notes:
@@ -977,9 +981,13 @@ 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.split()[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)
+ raise template.TemplateSyntaxError(
+ "%r tag's argument should be in quotes" % tag_name
+ )
return FormatTimeNode(date_to_be_formatted, format_string[1:-1])
You also have to change the renderer to retrieve the actual contents of the
@@ -1075,13 +1083,17 @@ 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.split()[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)
format_string, var_name = m.groups()
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)
+ raise template.TemplateSyntaxError(
+ "%r tag's argument should be in quotes" % tag_name
+ )
return CurrentTimeNode3(format_string[1:-1], var_name)
The difference here is that ``do_current_time()`` grabs the format string and