Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templater.py @ 37022:c97b936d8bb5
templater: use named function to expand template against mapping dict (API)
And replace __call__(t, **mapping) in favor of generate(t, mapping). I prefer
a named function here since the templater isn't a simple function-like object.
.. api::
The templater is no longer callable. Use ``templater.generate(t, mapping)``
instead of ``templater(t, **pycompat.strkwargs(mapping))``.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 16 Mar 2018 21:39:32 +0900 |
parents | a5311d7f4af8 |
children | 04aafcec00b9 |
line wrap: on
line diff
--- a/mercurial/templater.py Mon Mar 19 21:09:23 2018 +0900 +++ b/mercurial/templater.py Fri Mar 16 21:39:32 2018 +0900 @@ -770,11 +770,11 @@ def render(self, t, mapping): """Render the specified named template and return result as string""" - mapping = pycompat.strkwargs(mapping) - return templateutil.stringify(self(t, **mapping)) + return templateutil.stringify(self.generate(t, mapping)) - def __call__(self, t, **mapping): - mapping = pycompat.byteskwargs(mapping) + def generate(self, t, mapping): + """Return a generator that renders the specified named template and + yields chunks""" ttype = t in self.map and self.map[t][0] or 'default' if ttype not in self.ecache: try: