##// END OF EJS Templates
templater: drop 'templ' from resources dict...
Yuya Nishihara -
r37088:1101d674 default
parent child Browse files
Show More
@@ -35,19 +35,8 b' compatdict = templateutil.compatdict'
35 35 compatlist = templateutil.compatlist
36 36 _showcompatlist = templateutil._showcompatlist
37 37
38 # TODO: temporary hack for porting; will be removed soon
39 class _fakecontextwrapper(object):
40 def __init__(self, templ):
41 self._templ = templ
42
43 def preload(self, t):
44 return t in self._templ
45
46 def process(self, t, mapping):
47 return self._templ.generatenamed(t, mapping)
48
49 38 def _showlist(name, values, templ, mapping, plural=None, separator=' '):
50 context = _fakecontextwrapper(templ)
39 context = templ # this is actually a template context, not a templater
51 40 return _showcompatlist(context, mapping, name, values, plural, separator)
52 41
53 42 def showdict(name, data, mapping, plural=None, key='key', value='value',
@@ -738,8 +738,7 b' class templater(object):'
738 738 self.filters = templatefilters.filters.copy()
739 739 self.filters.update(filters)
740 740 self.defaults = defaults
741 self._resources = {'templ': lambda context, mapping, key: self}
742 self._resources.update(resources)
741 self._resources = resources
743 742 self._aliases = aliases
744 743 self.minchunk, self.maxchunk = minchunk, maxchunk
745 744 self.ecache = {}
@@ -348,8 +348,11 b' def runsymbol(context, mapping, key, def'
348 348 v = default
349 349 if callable(v) and getattr(v, '_requires', None) is None:
350 350 # old templatekw: expand all keywords and resources
351 # (TODO: deprecate this after porting web template keywords to new API)
351 352 props = {k: f(context, mapping, k)
352 353 for k, f in context._resources.items()}
354 # pass context to _showcompatlist() through templatekw._showlist()
355 props['templ'] = context
353 356 props.update(mapping)
354 357 return v(**pycompat.strkwargs(props))
355 358 if callable(v):
General Comments 0
You need to be logged in to leave comments. Login now