Show More
@@ -114,7 +114,7 b' schemes = {' | |||
|
114 | 114 | |
|
115 | 115 | def extsetup(ui): |
|
116 | 116 | schemes.update(dict(ui.configitems('schemes'))) |
|
117 |
t = templater.engine( |
|
|
117 | t = templater.engine(templater.parse) | |
|
118 | 118 | for scheme, url in schemes.items(): |
|
119 | 119 | if (pycompat.iswindows and len(scheme) == 1 and scheme.isalpha() |
|
120 | 120 | and os.path.exists('%s:\\' % scheme)): |
@@ -597,8 +597,7 b' class engine(object):' | |||
|
597 | 597 | filter uses function to transform value. syntax is |
|
598 | 598 | {key|filter1|filter2|...}.''' |
|
599 | 599 | |
|
600 |
def __init__(self, loader, filters=None, defaults=None, resources=None |
|
|
601 | aliases=()): | |
|
600 | def __init__(self, loader, filters=None, defaults=None, resources=None): | |
|
602 | 601 | self._loader = loader |
|
603 | 602 | if filters is None: |
|
604 | 603 | filters = {} |
@@ -610,7 +609,6 b' class engine(object):' | |||
|
610 | 609 | resources = nullresourcemapper() |
|
611 | 610 | self._defaults = defaults |
|
612 | 611 | self._resources = resources |
|
613 | self._aliasmap = _aliasrules.buildmap(aliases) | |
|
614 | 612 | self._cache = {} # key: (func, data) |
|
615 | 613 | self._tmplcache = {} # literal template: (func, data) |
|
616 | 614 | |
@@ -665,9 +663,7 b' class engine(object):' | |||
|
665 | 663 | def _load(self, t): |
|
666 | 664 | '''load, parse, and cache a template''' |
|
667 | 665 | if t not in self._cache: |
|
668 |
x = |
|
|
669 | if self._aliasmap: | |
|
670 | x = _aliasrules.expand(self._aliasmap, x) | |
|
666 | x = self._loader(t) | |
|
671 | 667 | # put poison to cut recursion while compiling 't' |
|
672 | 668 | self._cache[t] = (_runrecursivesymbol, t) |
|
673 | 669 | try: |
@@ -808,7 +804,7 b' class templater(object):' | |||
|
808 | 804 | self._filters.update(filters) |
|
809 | 805 | self.defaults = defaults |
|
810 | 806 | self._resources = resources |
|
811 |
self._alias |
|
|
807 | self._aliasmap = _aliasrules.buildmap(aliases) | |
|
812 | 808 | self._minchunk, self._maxchunk = minchunk, maxchunk |
|
813 | 809 | |
|
814 | 810 | @classmethod |
@@ -819,14 +815,14 b' class templater(object):' | |||
|
819 | 815 | cache, tmap, aliases = _readmapfile(mapfile) |
|
820 | 816 | t.cache.update(cache) |
|
821 | 817 | t._map = tmap |
|
822 |
t._alias |
|
|
818 | t._aliasmap = _aliasrules.buildmap(aliases) | |
|
823 | 819 | return t |
|
824 | 820 | |
|
825 | 821 | def __contains__(self, key): |
|
826 | 822 | return key in self.cache or key in self._map |
|
827 | 823 | |
|
828 | 824 | def load(self, t): |
|
829 |
|
|
|
825 | """Get parsed tree for the given template name. Use a local cache.""" | |
|
830 | 826 | if t not in self.cache: |
|
831 | 827 | try: |
|
832 | 828 | self.cache[t] = util.readfile(self._map[t]) |
@@ -838,7 +834,13 b' class templater(object):' | |||
|
838 | 834 | % (self._map[t], |
|
839 | 835 | stringutil.forcebytestr(inst.args[1]))) |
|
840 | 836 | raise IOError(inst.args[0], encoding.strfromlocal(reason)) |
|
841 | return self.cache[t] | |
|
837 | return self._parse(self.cache[t]) | |
|
838 | ||
|
839 | def _parse(self, tmpl): | |
|
840 | x = parse(tmpl) | |
|
841 | if self._aliasmap: | |
|
842 | x = _aliasrules.expand(self._aliasmap, x) | |
|
843 | return x | |
|
842 | 844 | |
|
843 | 845 | def renderdefault(self, mapping): |
|
844 | 846 | """Render the default unnamed template and return result as string""" |
@@ -851,8 +853,7 b' class templater(object):' | |||
|
851 | 853 | def generate(self, t, mapping): |
|
852 | 854 | """Return a generator that renders the specified named template and |
|
853 | 855 | yields chunks""" |
|
854 |
proc = engine(self.load, self._filters, self.defaults, self._resources |
|
|
855 | self._aliases) | |
|
856 | proc = engine(self.load, self._filters, self.defaults, self._resources) | |
|
856 | 857 | stream = proc.process(t, mapping) |
|
857 | 858 | if self._minchunk: |
|
858 | 859 | stream = util.increasingchunks(stream, min=self._minchunk, |
General Comments 0
You need to be logged in to leave comments.
Login now