comparison mercurial/templater.py @ 27892:83aef8d5bc1b

templater: make get(dict, key) return a single value This is necessary to obtain a _hybrid object from a dict. If get() yields a value, it would be stringified. I see no benefit to make get() lazy, so this patch just changes "yield" to "return".
author Yuya Nishihara <yuya@tcha.org>
date Sat, 16 Jan 2016 13:53:32 +0900
parents ac8c0ee5c3b8
children 7ed3a3c0cef1
comparison
equal deleted inserted replaced
27891:ac8c0ee5c3b8 27892:83aef8d5bc1b
430 if not util.safehasattr(dictarg, 'get'): 430 if not util.safehasattr(dictarg, 'get'):
431 # i18n: "get" is a keyword 431 # i18n: "get" is a keyword
432 raise error.ParseError(_("get() expects a dict as first argument")) 432 raise error.ParseError(_("get() expects a dict as first argument"))
433 433
434 key = args[1][0](context, mapping, args[1][1]) 434 key = args[1][0](context, mapping, args[1][1])
435 yield dictarg.get(key) 435 return dictarg.get(key)
436 436
437 def if_(context, mapping, args): 437 def if_(context, mapping, args):
438 """:if(expr, then[, else]): Conditionally execute based on the result of 438 """:if(expr, then[, else]): Conditionally execute based on the result of
439 an expression.""" 439 an expression."""
440 if not (2 <= len(args) <= 3): 440 if not (2 <= len(args) <= 3):