Ticket #10912: firstof_autoescape_t10912_r10630.diff
File firstof_autoescape_t10912_r10630.diff, 1.9 KB (added by , 16 years ago) |
---|
-
django/template/defaulttags.py
10 10 11 11 from django.template import Node, NodeList, Template, Context, Variable 12 12 from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END 13 from django.template import get_library, Library, InvalidTemplateLibrary 13 from django.template import get_library, Library, InvalidTemplateLibrary, _render_value_in_context 14 14 from django.conf import settings 15 from django.utils.encoding import smart_str , smart_unicode15 from django.utils.encoding import smart_str 16 16 from django.utils.itercompat import groupby 17 17 from django.utils.safestring import mark_safe 18 18 … … 76 76 for var in self.vars: 77 77 value = var.resolve(context, True) 78 78 if value: 79 return smart_unicode(value)79 return _render_value_in_context(value, context) 80 80 return u'' 81 81 82 82 class ForNode(Node): -
tests/regressiontests/templates/tests.py
501 501 'firstof07': ('{% firstof a b "c" %}', {'a':0}, 'c'), 502 502 'firstof08': ('{% firstof a b "c and d" %}', {'a':0,'b':0}, 'c and d'), 503 503 'firstof09': ('{% firstof %}', {}, template.TemplateSyntaxError), 504 'firstof10': ('{% firstof a %}', {'a': '<'}, '<'), 504 505 505 506 ### FOR TAG ############################################################### 506 507 'for-tag01': ("{% for val in values %}{{ val }}{% endfor %}", {"values": [1, 2, 3]}, "123"),