mercurial/templater.py
changeset 36445 e8d37838f5df
parent 36444 717a279c0c21
child 36500 43e108027b0d
--- a/mercurial/templater.py	Sun Feb 25 12:50:30 2018 +0900
+++ b/mercurial/templater.py	Sun Feb 25 13:24:35 2018 +0900
@@ -436,12 +436,18 @@
             v = context.process(key, safemapping)
         except TemplateNotFound:
             v = default
-    if callable(v):
-        # TODO: templatekw functions will be updated to take (context, mapping)
-        # pair instead of **props
+    if callable(v) and getattr(v, '_requires', None) is None:
+        # old templatekw: expand all keywords and resources
         props = context._resources.copy()
         props.update(mapping)
         return v(**pycompat.strkwargs(props))
+    if callable(v):
+        # new templatekw
+        try:
+            return v(context, mapping)
+        except ResourceUnavailable:
+            # unsupported keyword is mapped to empty just like unknown keyword
+            return None
     return v
 
 def buildtemplate(exp, context):