Mercurial > hg-stable
changeset 17632:523625e46760
templater: factor out runtemplate method
As a side-effect, this makes the output of runmap non-flattened
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 22 Sep 2012 13:02:33 -0500 |
parents | 0b241d7a8c62 |
children | 312184f930b7 |
files | mercurial/templater.py |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templater.py Fri Sep 21 18:54:00 2012 -0500 +++ b/mercurial/templater.py Sat Sep 22 13:02:33 2012 -0500 @@ -161,6 +161,10 @@ ctmpl = gettemplate(exp[2], context) return (runmap, (func, data, ctmpl)) +def runtemplate(context, mapping, template): + for func, data in template: + yield func(context, mapping, data) + def runmap(context, mapping, data): func, data, ctmpl = data d = func(context, mapping, data) @@ -172,8 +176,7 @@ for i in d: if isinstance(i, dict): lm.update(i) - for f, d in ctmpl: - yield f(context, lm, d) + yield runtemplate(context, lm, ctmpl) else: # v is not an iterable of dicts, this happen when 'key' # has been fully expanded already and format is useless. @@ -276,6 +279,7 @@ generator.''' return _flatten(func(self, mapping, data) for func, data in self._load(t)) + return _flatten(runtemplate(self, mapping, self._load(t))) engines = {'default': engine}