##// END OF EJS Templates
templater: extract private function to evaluate generator to byte string
Yuya Nishihara -
r37296:671a01cd default
parent child Browse files
Show More
@@ -313,6 +313,12 b' def findsymbolicname(arg):'
313 else:
313 else:
314 return None
314 return None
315
315
316 def _unthunk(context, mapping, thing):
317 """Evaluate a lazy byte string into value"""
318 if not isinstance(thing, types.GeneratorType):
319 return thing
320 return stringify(context, mapping, thing)
321
316 def evalrawexp(context, mapping, arg):
322 def evalrawexp(context, mapping, arg):
317 """Evaluate given argument as a bare template object which may require
323 """Evaluate given argument as a bare template object which may require
318 further processing (such as folding generator of strings)"""
324 further processing (such as folding generator of strings)"""
@@ -330,9 +336,7 b' def _unwrapvalue(context, mapping, thing'
330 thing = unwrapvalue(context, mapping, thing)
336 thing = unwrapvalue(context, mapping, thing)
331 # evalrawexp() may return string, generator of strings or arbitrary object
337 # evalrawexp() may return string, generator of strings or arbitrary object
332 # such as date tuple, but filter does not want generator.
338 # such as date tuple, but filter does not want generator.
333 if isinstance(thing, types.GeneratorType):
339 return _unthunk(context, mapping, thing)
334 thing = stringify(context, mapping, thing)
335 return thing
336
340
337 def evalboolean(context, mapping, arg):
341 def evalboolean(context, mapping, arg):
338 """Evaluate given argument as boolean, but also takes boolean literals"""
342 """Evaluate given argument as boolean, but also takes boolean literals"""
General Comments 0
You need to be logged in to leave comments. Login now