Ticket #6948: defaultfilters.patch
File defaultfilters.patch, 1.3 KB (added by , 17 years ago) |
---|
-
django/template/defaultfilters.py
11 11 from django.conf import settings 12 12 from django.utils.translation import ugettext, ungettext 13 13 from django.utils.encoding import force_unicode, iri_to_uri 14 from django.utils.html import conditional_escape 14 15 from django.utils.safestring import mark_safe, SafeData 15 16 16 17 register = Library() … … 442 443 return u'' 443 444 first.is_safe = False 444 445 445 def join(value, arg ):446 def join(value, arg, autoescape=None): 446 447 """Joins a list with a string, like Python's ``str.join(list)``.""" 447 448 try: 448 data = arg.join(map(force_unicode, value)) 449 esc = autoescape and conditional_escape or (lambda x: x) 450 data = arg.join(map(esc, map(force_unicode, value))) 449 451 except AttributeError: # fail silently but nicely 450 452 return value 451 safe_args = reduce(lambda lhs, rhs: lhs and isinstance(rhs, SafeData), 452 value, True) 453 if safe_args: 454 return mark_safe(data) 455 else: 456 return data 453 return mark_safe(data) 457 454 join.is_safe = True 455 join.needs_autoescape = True 458 456 459 457 def last(value): 460 458 "Returns the last item in a list"