##// END OF EJS Templates
templater: drop unneeded destructuring of argument tuple at buildfilter...
Yuya Nishihara -
r26125:c990afab default
parent child Browse files
Show More
@@ -256,26 +256,26 b' def runtemplate(context, mapping, templa'
256 yield func(context, mapping, data)
256 yield func(context, mapping, data)
257
257
258 def buildfilter(exp, context):
258 def buildfilter(exp, context):
259 func, data = compileexp(exp[1], context, methods)
259 arg = compileexp(exp[1], context, methods)
260 n = getsymbol(exp[2])
260 n = getsymbol(exp[2])
261 if n in context._filters:
261 if n in context._filters:
262 filt = context._filters[n]
262 filt = context._filters[n]
263 return (runfilter, (func, data, filt))
263 return (runfilter, (arg, filt))
264 if n in funcs:
264 if n in funcs:
265 f = funcs[n]
265 f = funcs[n]
266 return (f, [(func, data)])
266 return (f, [arg])
267 raise error.ParseError(_("unknown function '%s'") % n)
267 raise error.ParseError(_("unknown function '%s'") % n)
268
268
269 def runfilter(context, mapping, data):
269 def runfilter(context, mapping, data):
270 func, data, filt = data
270 arg, filt = data
271 thing = evalfuncarg(context, mapping, (func, data))
271 thing = evalfuncarg(context, mapping, arg)
272 try:
272 try:
273 return filt(thing)
273 return filt(thing)
274 except (ValueError, AttributeError, TypeError):
274 except (ValueError, AttributeError, TypeError):
275 if isinstance(data, tuple):
275 if isinstance(arg[1], tuple):
276 dt = data[1]
276 dt = arg[1][1]
277 else:
277 else:
278 dt = data
278 dt = arg[1]
279 raise util.Abort(_("template filter '%s' is not compatible with "
279 raise util.Abort(_("template filter '%s' is not compatible with "
280 "keyword '%s'") % (filt.func_name, dt))
280 "keyword '%s'") % (filt.func_name, dt))
281
281
@@ -313,7 +313,7 b' def buildfunc(exp, context):'
313 if len(args) != 1:
313 if len(args) != 1:
314 raise error.ParseError(_("filter %s expects one argument") % n)
314 raise error.ParseError(_("filter %s expects one argument") % n)
315 f = context._filters[n]
315 f = context._filters[n]
316 return (runfilter, (args[0][0], args[0][1], f))
316 return (runfilter, (args[0], f))
317 raise error.ParseError(_("unknown function '%s'") % n)
317 raise error.ParseError(_("unknown function '%s'") % n)
318
318
319 def date(context, mapping, args):
319 def date(context, mapping, args):
General Comments 0
You need to be logged in to leave comments. Login now