mercurial/templater.py
changeset 36986 036e4483d3a1
parent 36985 255f635c3204
child 36990 4b744c7b35ce
equal deleted inserted replaced
36985:255f635c3204 36986:036e4483d3a1
   563     def resource(self, mapping, key):
   563     def resource(self, mapping, key):
   564         """Return internal data (e.g. cache) used for keyword/function
   564         """Return internal data (e.g. cache) used for keyword/function
   565         evaluation"""
   565         evaluation"""
   566         v = None
   566         v = None
   567         if key in self._resources:
   567         if key in self._resources:
   568             v = mapping.get(key)
       
   569         if v is None and key in self._resources:
       
   570             v = self._resources[key](self, mapping, key)
   568             v = self._resources[key](self, mapping, key)
   571         if v is None:
   569         if v is None:
   572             raise templateutil.ResourceUnavailable(
   570             raise templateutil.ResourceUnavailable(
   573                 _('template resource not available: %s') % key)
   571                 _('template resource not available: %s') % key)
   574         return v
   572         return v
   669 
   667 
   670         - ``filters``: a dict of functions to transform a value into another.
   668         - ``filters``: a dict of functions to transform a value into another.
   671         - ``defaults``: a dict of symbol values/functions; may be overridden
   669         - ``defaults``: a dict of symbol values/functions; may be overridden
   672           by a ``mapping`` dict.
   670           by a ``mapping`` dict.
   673         - ``resources``: a dict of functions returning internal data
   671         - ``resources``: a dict of functions returning internal data
   674           (e.g. cache), inaccessible from user template; may be overridden by
   672           (e.g. cache), inaccessible from user template.
   675           a ``mapping`` dict.
       
   676         - ``cache``: a dict of preloaded template fragments.
   673         - ``cache``: a dict of preloaded template fragments.
   677         - ``aliases``: a list of alias (name, replacement) pairs.
   674         - ``aliases``: a list of alias (name, replacement) pairs.
   678 
   675 
   679         self.cache may be updated later to register additional template
   676         self.cache may be updated later to register additional template
   680         fragments.
   677         fragments.