Ticket #8902: with_patch_test.diff
File with_patch_test.diff, 1.9 KB (added by , 16 years ago) |
---|
-
django/template/defaulttags.py
1123 1123 {{ total }} object{{ total|pluralize }} 1124 1124 {% endwith %} 1125 1125 """ 1126 bits = list(token. split_contents())1127 if len(bits) != 4 or bits[2] != "as":1126 bits = list(token.contents.split()) 1127 if bits[-2] != "as": 1128 1128 raise TemplateSyntaxError("%r expected format is 'value as name'" % 1129 1129 bits[0]) 1130 var = parser.compile_filter(bits[1]) 1131 name = bits[3] 1130 1131 var = parser.compile_filter(' '.join(bits[1:-2])) 1132 name = bits[-1] 1132 1133 nodelist = parser.parse(('endwith',)) 1133 1134 parser.delete_first_token() 1134 1135 return WithNode(var, name, nodelist) -
tests/regressiontests/templates/tests.py
877 877 ### WITH TAG ######################################################## 878 878 'with01': ('{% with dict.key as key %}{{ key }}{% endwith %}', {'dict': {'key':50}}, '50'), 879 879 'with02': ('{{ key }}{% with dict.key as key %}{{ key }}-{{ dict.key }}-{{ key }}{% endwith %}{{ key }}', {'dict': {'key':50}}, ('50-50-50', 'INVALID50-50-50INVALID')), 880 880 'with03': ('{% with input|cut:" " as cutted %}{{ cutted }}{% endwith %}', {'input': 'string with spaces'}, 'stringwithspaces'), 881 881 882 'with-error01': ('{% with dict.key xx key %}{{ key }}{% endwith %}', {'dict': {'key':50}}, template.TemplateSyntaxError), 882 883 'with-error02': ('{% with dict.key as %}{{ key }}{% endwith %}', {'dict': {'key':50}}, template.TemplateSyntaxError), 883 884