comparison mercurial/templatefuncs.py @ 38225:d48b80d58848

templater: unify unwrapvalue() with _unwrapvalue() All weird generators got removed from the hgweb codebase. We still have inconsistent behavior regarding join() of a byte string, which will be addressed later.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 04 Apr 2018 21:06:14 +0900
parents bd7a3fa71a72
children 1c8098cf560a
comparison
equal deleted inserted replaced
38224:61cecab0cc20 38225:d48b80d58848
331 joiner = " " 331 joiner = " "
332 if len(args) > 1: 332 if len(args) > 1:
333 joiner = evalstring(context, mapping, args[1]) 333 joiner = evalstring(context, mapping, args[1])
334 if isinstance(joinset, templateutil.wrapped): 334 if isinstance(joinset, templateutil.wrapped):
335 return joinset.join(context, mapping, joiner) 335 return joinset.join(context, mapping, joiner)
336 # TODO: perhaps a generator should be stringify()-ed here, but we can't 336 # TODO: rethink about join() of a byte string, which had no defined
337 # because hgweb abuses it as a keyword that returns a list of dicts. 337 # behavior since a string may be either a bytes or a generator.
338 # TODO: fix type error on join() of non-iterable
338 joinset = templateutil.unwrapvalue(context, mapping, joinset) 339 joinset = templateutil.unwrapvalue(context, mapping, joinset)
339 return templateutil.joinitems(pycompat.maybebytestr(joinset), joiner) 340 return templateutil.joinitems(pycompat.maybebytestr(joinset), joiner)
340 341
341 @templatefunc('label(label, expr)') 342 @templatefunc('label(label, expr)')
342 def label(context, mapping, args): 343 def label(context, mapping, args):