comparison mercurial/templater.py @ 37067:04aafcec00b9

templater: add context.preload(t) to test if the specified template exists I'm going to remove 'templ' from the resources dict because it is the only resource that the caller can't provide. This also implies that putting 'templ' into the resources dict creates a reference cycle. context.preload(t) will be used in place of templater.__contains__().
author Yuya Nishihara <yuya@tcha.org>
date Fri, 16 Mar 2018 22:36:40 +0900
parents c97b936d8bb5
children 1101d6747d2d
comparison
equal deleted inserted replaced
37066:b33b91ca2ec2 37067:04aafcec00b9
625 except: # re-raises 625 except: # re-raises
626 del self._cache[t] 626 del self._cache[t]
627 raise 627 raise
628 return self._cache[t] 628 return self._cache[t]
629 629
630 def preload(self, t):
631 """Load, parse, and cache the specified template if available"""
632 try:
633 self._load(t)
634 return True
635 except templateutil.TemplateNotFound:
636 return False
637
630 def process(self, t, mapping): 638 def process(self, t, mapping):
631 '''Perform expansion. t is name of map element to expand. 639 '''Perform expansion. t is name of map element to expand.
632 mapping contains added elements for use during expansion. Is a 640 mapping contains added elements for use during expansion. Is a
633 generator.''' 641 generator.'''
634 func, data = self._load(t) 642 func, data = self._load(t)