Ticket #5270: 5270-empty-string-template-w-tests.diff
File 5270-empty-string-template-w-tests.diff, 2.9 KB (added by , 16 years ago) |
---|
-
django/template/__init__.py
485 485 (token[:upto], token[upto:start], token[start:])) 486 486 if var == None: 487 487 var, constant, i18n_constant = match.group("var", "constant", "i18n_constant") 488 if i18n_constant: 489 var = '"%s"' % _(i18n_constant.replace(r'\"', '"')) 490 elif constant: 488 if i18n_constant is not None: 489 if i18n_constant == "": 490 var = '""' 491 else: 492 var = '"%s"' % _(i18n_constant.replace(r'\"', '"')) 493 elif constant is not None: 491 494 var = '"%s"' % constant.replace(r'\"', '"') 492 495 upto = match.end() 493 496 if var == None: -
tests/regressiontests/templates/tests.py
365 365 366 366 # Numbers as filter arguments should work 367 367 'filter-syntax19': ('{{ var|truncatewords:1 }}', {"var": "hello world"}, "hello ..."), 368 369 #filters should accept empty string constants 370 'filter-syntax20': ('{{ ""|default_if_none:"was none" }}', {}, ""), 368 371 369 372 ### COMMENT SYNTAX ######################################################## 370 373 'comment-syntax01': ("{# this is hidden #}hello", {}, "hello"), … … 770 773 'i18n14': ('{% cycle "foo" _("Password") _(\'Password\') as c %} {% cycle c %} {% cycle c %}', {'LANGUAGE_CODE': 'de'}, 'foo Passwort Passwort'), 771 774 'i18n15': ('{{ absent|default:_("Password") }}', {'LANGUAGE_CODE': 'de', 'absent': ""}, 'Passwort'), 772 775 'i18n16': ('{{ _("<") }}', {'LANGUAGE_CODE': 'de'}, '<'), 776 'i18n17': ('{{ _("") }}', {'LANGUAGE_CODE': 'de'}, ''), 773 777 774 778 # Escaping inside blocktrans works as if it was directly in the 775 779 # template. 776 'i18n1 7': ('{% load i18n %}{% blocktrans with anton|escape as berta %}{{ berta }}{% endblocktrans %}', {'anton': 'α & β'}, u'α & β'),777 'i18n1 8': ('{% load i18n %}{% blocktrans with anton|force_escape as berta %}{{ berta }}{% endblocktrans %}', {'anton': 'α & β'}, u'α & β'),780 'i18n18': ('{% load i18n %}{% blocktrans with anton|escape as berta %}{{ berta }}{% endblocktrans %}', {'anton': 'α & β'}, u'α & β'), 781 'i18n19': ('{% load i18n %}{% blocktrans with anton|force_escape as berta %}{{ berta }}{% endblocktrans %}', {'anton': 'α & β'}, u'α & β'), 778 782 779 783 ### HANDLING OF TEMPLATE_STRING_IF_INVALID ################################### 780 784