Ticket #7239: patch_django_7239.20080530.diff
File patch_django_7239.20080530.diff, 1.9 KB (added by , 16 years ago) |
---|
-
django/templatetags/i18n.py
3 3 from django.template import Node, Variable, VariableNode 4 4 from django.template import TemplateSyntaxError, TokenParser, Library 5 5 from django.template import TOKEN_TEXT, TOKEN_VAR 6 from django.template.defaulttags import URLNode 6 7 from django.utils import translation 7 8 from django.utils.encoding import force_unicode 8 9 … … 218 219 raise TemplateSyntaxError, "variable bindings in 'blocktrans' must be 'with value as variable'" 219 220 extra_context[self.tag()] = VariableNode( 220 221 parser.compile_filter(value)) 222 elif tag == 'url': 223 args = [] 224 kwargs = {} 225 value = self.value() 226 next_tag = self.tag() 227 if next_tag != 'as': 228 if self.tag() != 'as': 229 raise TemplateSyntaxError, "variable bindings in 'blocktrans' must be 'url path.to.some_view arg1,arg2,name1=value1 as variable'" 230 else: 231 # can't find way to do not duplicate code from url tag 232 for arg in next_tag.split(','): 233 if '=' in arg: 234 k, v = arg.split('=', 1) 235 k = k.strip() 236 kwargs[k] = parser.compile_filter(v) 237 else: 238 args.append(parser.compile_filter(arg)) 239 extra_context[self.tag()] = URLNode(value, args, kwargs) 221 240 elif tag == 'count': 222 241 counter = parser.compile_filter(self.value()) 223 242 if self.tag() != 'as':