Ticket #6766: template_invalid__loop.diff
File template_invalid__loop.diff, 2.2 KB (added by , 17 years ago) |
---|
-
tests/regressiontests/templates/tests.py
759 759 760 760 'invalidstr01': ('{{ var|default:"Foo" }}', {}, ('Foo','INVALID')), 761 761 'invalidstr02': ('{{ var|default_if_none:"Foo" }}', {}, ('','INVALID')), 762 'invalidstr03': ('{% for v in var %}({{ v }}){% endfor %}', {}, ''),762 'invalidstr03': ('{% for v in var %}({{ v }}){% endfor %}', {}, ('', 'INVALID')), 763 763 'invalidstr04': ('{% if var %}Yes{% else %}No{% endif %}', {}, 'No'), 764 764 'invalidstr04': ('{% if var|default:"Foo" %}Yes{% else %}No{% endif %}', {}, 'Yes'), 765 765 'invalidstr05': ('{{ var }}', {}, ('', 'INVALID %s', 'var')), -
django/template/__init__.py
510 510 self.filters = filters 511 511 self.var = Variable(var) 512 512 513 def resolve(self, context, ignore_failures=False ):513 def resolve(self, context, ignore_failures=False, raise_failures=False): 514 514 try: 515 515 obj = self.var.resolve(context) 516 516 except VariableDoesNotExist: 517 517 if ignore_failures: 518 518 obj = None 519 elif raise_failures: 520 raise 519 521 else: 520 522 if settings.TEMPLATE_STRING_IF_INVALID: 521 523 global invalid_var_format_string -
django/template/defaulttags.py
114 114 parentloop = {} 115 115 context.push() 116 116 try: 117 values = self.sequence.resolve(context, True)117 values = self.sequence.resolve(context, raise_failures=True) 118 118 except VariableDoesNotExist: 119 if settings.TEMPLATE_STRING_IF_INVALID: 120 return settings.TEMPLATE_STRING_IF_INVALID % self.sequence 119 121 values = [] 120 122 if values is None: 121 123 values = []