Changeset 4502
- Timestamp:
- 02/13/07 09:44:04 (2 years ago)
- Files:
-
- django/trunk/docs/templates_python.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/templates_python.txt
r4477 r4502 830 830 try: 831 831 # split_contents() knows not to split quoted strings. 832 tag_name, date_to_ format, format_string = token.split_contents()832 tag_name, date_to_be_formatted, format_string = token.split_contents() 833 833 except ValueError: 834 834 raise template.TemplateSyntaxError, "%r tag requires exactly two arguments" % token.contents[0] 835 835 if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")): 836 836 raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name 837 return FormatTimeNode(date_to_ format, format_string[1:-1])837 return FormatTimeNode(date_to_be_formatted, format_string[1:-1]) 838 838 839 839 You also have to change the renderer to retrieve the actual contents of the … … 847 847 import datetime 848 848 class FormatTimeNode(template.Node): 849 def __init__(self, date_to_ format, format_string):850 self.date_to_ format = date_to_format849 def __init__(self, date_to_be_formatted, format_string): 850 self.date_to_be_formatted = date_to_be_formatted 851 851 self.format_string = format_string 852 852 853 853 def render(self, context): 854 854 try: 855 actual_date = resolve_variable(self.date_to_ format, context)855 actual_date = resolve_variable(self.date_to_be_formatted, context) 856 856 return actual_date.strftime(self.format_string) 857 857 except VariableDoesNotExist:
