mercurial/templater.py
changeset 36445 e8d37838f5df
parent 36444 717a279c0c21
child 36500 43e108027b0d
equal deleted inserted replaced
36444:717a279c0c21 36445:e8d37838f5df
   434         safemapping[key] = _recursivesymbolblocker(key)
   434         safemapping[key] = _recursivesymbolblocker(key)
   435         try:
   435         try:
   436             v = context.process(key, safemapping)
   436             v = context.process(key, safemapping)
   437         except TemplateNotFound:
   437         except TemplateNotFound:
   438             v = default
   438             v = default
   439     if callable(v):
   439     if callable(v) and getattr(v, '_requires', None) is None:
   440         # TODO: templatekw functions will be updated to take (context, mapping)
   440         # old templatekw: expand all keywords and resources
   441         # pair instead of **props
       
   442         props = context._resources.copy()
   441         props = context._resources.copy()
   443         props.update(mapping)
   442         props.update(mapping)
   444         return v(**pycompat.strkwargs(props))
   443         return v(**pycompat.strkwargs(props))
       
   444     if callable(v):
       
   445         # new templatekw
       
   446         try:
       
   447             return v(context, mapping)
       
   448         except ResourceUnavailable:
       
   449             # unsupported keyword is mapped to empty just like unknown keyword
       
   450             return None
   445     return v
   451     return v
   446 
   452 
   447 def buildtemplate(exp, context):
   453 def buildtemplate(exp, context):
   448     ctmpl = [compileexp(e, context, methods) for e in exp[1:]]
   454     ctmpl = [compileexp(e, context, methods) for e in exp[1:]]
   449     return (runtemplate, ctmpl)
   455     return (runtemplate, ctmpl)