##// END OF EJS Templates
templatekw: deprecate old-style template keyword function (API)...
Yuya Nishihara -
r38966:382b055c default
parent child Browse files
Show More
@@ -295,7 +295,7 b' class templatekeyword(_templateregistrar'
295 '''
295 '''
296 pass
296 pass
297
297
298 # old API
298 # old API (DEPRECATED)
299 @templatekeyword('mykeyword')
299 @templatekeyword('mykeyword')
300 def mykeywordfunc(repo, ctx, templ, cache, revcache, **args):
300 def mykeywordfunc(repo, ctx, templ, cache, revcache, **args):
301 '''Explanation of this template keyword ....
301 '''Explanation of this template keyword ....
@@ -810,8 +810,9 b' 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=''):
@@ -827,12 +828,16 b' def runsymbol(context, mapping, key, def'
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
General Comments 0
You need to be logged in to leave comments. Login now