##// END OF EJS Templates
templater: drop extension point of engine classes (API)...
Yuya Nishihara -
r38609:48289eaf default
parent child Browse files
Show More
@@ -485,7 +485,6 b' test-symlink-placeholder.t'
485 test-symlinks.t
485 test-symlinks.t
486 test-tag.t
486 test-tag.t
487 test-tags.t
487 test-tags.t
488 test-template-engine.t
489 test-template-filters.t
488 test-template-filters.t
490 test-treemanifest.t
489 test-treemanifest.t
491 test-ui-color.py
490 test-ui-color.py
@@ -718,8 +718,6 b' class engine(object):'
718 mapping = extramapping
718 mapping = extramapping
719 return templateutil.flatten(self, mapping, func(self, mapping, data))
719 return templateutil.flatten(self, mapping, func(self, mapping, data))
720
720
721 engines = {'default': engine}
722
723 def stylelist():
721 def stylelist():
724 paths = templatepaths()
722 paths = templatepaths()
725 if not paths:
723 if not paths:
@@ -777,10 +775,7 b' def _readmapfile(mapfile):'
777 conf.source('templates', key))
775 conf.source('templates', key))
778 cache[key] = unquotestring(val)
776 cache[key] = unquotestring(val)
779 elif key != '__base__':
777 elif key != '__base__':
780 val = 'default', val
778 tmap[key] = os.path.join(base, val)
781 if ':' in val[1]:
782 val = val[1].split(':', 1)
783 tmap[key] = val[0], os.path.join(base, val[1])
784 aliases.extend(conf['templatealias'].items())
779 aliases.extend(conf['templatealias'].items())
785 return cache, tmap, aliases
780 return cache, tmap, aliases
786
781
@@ -815,7 +810,6 b' class templater(object):'
815 self._resources = resources
810 self._resources = resources
816 self._aliases = aliases
811 self._aliases = aliases
817 self._minchunk, self._maxchunk = minchunk, maxchunk
812 self._minchunk, self._maxchunk = minchunk, maxchunk
818 self._ecache = {}
819
813
820 @classmethod
814 @classmethod
821 def frommapfile(cls, mapfile, filters=None, defaults=None, resources=None,
815 def frommapfile(cls, mapfile, filters=None, defaults=None, resources=None,
@@ -835,13 +829,13 b' class templater(object):'
835 '''Get the template for the given template name. Use a local cache.'''
829 '''Get the template for the given template name. Use a local cache.'''
836 if t not in self.cache:
830 if t not in self.cache:
837 try:
831 try:
838 self.cache[t] = util.readfile(self._map[t][1])
832 self.cache[t] = util.readfile(self._map[t])
839 except KeyError as inst:
833 except KeyError as inst:
840 raise templateutil.TemplateNotFound(
834 raise templateutil.TemplateNotFound(
841 _('"%s" not in template map') % inst.args[0])
835 _('"%s" not in template map') % inst.args[0])
842 except IOError as inst:
836 except IOError as inst:
843 reason = (_('template file %s: %s')
837 reason = (_('template file %s: %s')
844 % (self._map[t][1],
838 % (self._map[t],
845 stringutil.forcebytestr(inst.args[1])))
839 stringutil.forcebytestr(inst.args[1])))
846 raise IOError(inst.args[0], encoding.strfromlocal(reason))
840 raise IOError(inst.args[0], encoding.strfromlocal(reason))
847 return self.cache[t]
841 return self.cache[t]
@@ -857,16 +851,8 b' class templater(object):'
857 def generate(self, t, mapping):
851 def generate(self, t, mapping):
858 """Return a generator that renders the specified named template and
852 """Return a generator that renders the specified named template and
859 yields chunks"""
853 yields chunks"""
860 ttype = t in self._map and self._map[t][0] or 'default'
854 proc = engine(self.load, self._filters, self.defaults, self._resources,
861 if ttype not in self._ecache:
855 self._aliases)
862 try:
863 ecls = engines[ttype]
864 except KeyError:
865 raise error.Abort(_('invalid template engine: %s') % ttype)
866 self._ecache[ttype] = ecls(self.load, self._filters, self.defaults,
867 self._resources, self._aliases)
868 proc = self._ecache[ttype]
869
870 stream = proc.process(t, mapping)
856 stream = proc.process(t, mapping)
871 if self._minchunk:
857 if self._minchunk:
872 stream = util.increasingchunks(stream, min=self._minchunk,
858 stream = util.increasingchunks(stream, min=self._minchunk,
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now