mercurial/templateutil.py
changeset 38930 382b055cc358
parent 38449 bc8d925342f0
child 39367 83f8f7b9fa60
equal deleted inserted replaced
38929:d7e6e109eaae 38930:382b055cc358
   808 
   808 
   809 def runstring(context, mapping, data):
   809 def runstring(context, mapping, data):
   810     return data
   810     return data
   811 
   811 
   812 def _recursivesymbolblocker(key):
   812 def _recursivesymbolblocker(key):
   813     def showrecursion(**args):
   813     def showrecursion(context, mapping):
   814         raise error.Abort(_("recursive reference '%s' in template") % key)
   814         raise error.Abort(_("recursive reference '%s' in template") % key)
       
   815     showrecursion._requires = ()  # mark as new-style templatekw
   815     return showrecursion
   816     return showrecursion
   816 
   817 
   817 def runsymbol(context, mapping, key, default=''):
   818 def runsymbol(context, mapping, key, default=''):
   818     v = context.symbol(mapping, key)
   819     v = context.symbol(mapping, key)
   819     if v is None:
   820     if v is None:
   825             v = context.process(key, safemapping)
   826             v = context.process(key, safemapping)
   826         except TemplateNotFound:
   827         except TemplateNotFound:
   827             v = default
   828             v = default
   828     if callable(v) and getattr(v, '_requires', None) is None:
   829     if callable(v) and getattr(v, '_requires', None) is None:
   829         # old templatekw: expand all keywords and resources
   830         # old templatekw: expand all keywords and resources
   830         # (TODO: deprecate this after porting web template keywords to new API)
   831         # (TODO: drop support for old-style functions. 'f._requires = ()'
       
   832         #  can be removed.)
   831         props = {k: context._resources.lookup(context, mapping, k)
   833         props = {k: context._resources.lookup(context, mapping, k)
   832                  for k in context._resources.knownkeys()}
   834                  for k in context._resources.knownkeys()}
   833         # pass context to _showcompatlist() through templatekw._showlist()
   835         # pass context to _showcompatlist() through templatekw._showlist()
   834         props['templ'] = context
   836         props['templ'] = context
   835         props.update(mapping)
   837         props.update(mapping)
       
   838         ui = props.get('ui')
       
   839         if ui:
       
   840             ui.deprecwarn("old-style template keyword '%s'" % key, '4.8')
   836         return v(**pycompat.strkwargs(props))
   841         return v(**pycompat.strkwargs(props))
   837     if callable(v):
   842     if callable(v):
   838         # new templatekw
   843         # new templatekw
   839         try:
   844         try:
   840             return v(context, mapping)
   845             return v(context, mapping)