Show More
@@ -35,19 +35,8 compatdict = templateutil.compatdict | |||||
35 | compatlist = templateutil.compatlist |
|
35 | compatlist = templateutil.compatlist | |
36 | _showcompatlist = templateutil._showcompatlist |
|
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 | def _showlist(name, values, templ, mapping, plural=None, separator=' '): |
|
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 | return _showcompatlist(context, mapping, name, values, plural, separator) |
|
40 | return _showcompatlist(context, mapping, name, values, plural, separator) | |
52 |
|
41 | |||
53 | def showdict(name, data, mapping, plural=None, key='key', value='value', |
|
42 | def showdict(name, data, mapping, plural=None, key='key', value='value', |
@@ -738,8 +738,7 class templater(object): | |||||
738 | self.filters = templatefilters.filters.copy() |
|
738 | self.filters = templatefilters.filters.copy() | |
739 | self.filters.update(filters) |
|
739 | self.filters.update(filters) | |
740 | self.defaults = defaults |
|
740 | self.defaults = defaults | |
741 | self._resources = {'templ': lambda context, mapping, key: self} |
|
741 | self._resources = resources | |
742 | self._resources.update(resources) |
|
|||
743 | self._aliases = aliases |
|
742 | self._aliases = aliases | |
744 | self.minchunk, self.maxchunk = minchunk, maxchunk |
|
743 | self.minchunk, self.maxchunk = minchunk, maxchunk | |
745 | self.ecache = {} |
|
744 | self.ecache = {} |
@@ -348,8 +348,11 def runsymbol(context, mapping, key, def | |||||
348 | v = default |
|
348 | v = default | |
349 | if callable(v) and getattr(v, '_requires', None) is None: |
|
349 | if callable(v) and getattr(v, '_requires', None) is None: | |
350 | # old templatekw: expand all keywords and resources |
|
350 | # old templatekw: expand all keywords and resources | |
|
351 | # (TODO: deprecate this after porting web template keywords to new API) | |||
351 | props = {k: f(context, mapping, k) |
|
352 | props = {k: f(context, mapping, k) | |
352 | for k, f in context._resources.items()} |
|
353 | for k, f in context._resources.items()} | |
|
354 | # pass context to _showcompatlist() through templatekw._showlist() | |||
|
355 | props['templ'] = context | |||
353 | props.update(mapping) |
|
356 | props.update(mapping) | |
354 | return v(**pycompat.strkwargs(props)) |
|
357 | return v(**pycompat.strkwargs(props)) | |
355 | if callable(v): |
|
358 | if callable(v): |
General Comments 0
You need to be logged in to leave comments.
Login now