Mercurial > hg
changeset 28956:eea98190ed73
templater: inline compiletemplate() function into engine
This allows the template engine to modify parsed tree.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 03 Apr 2016 13:23:40 +0900 |
parents | 78759f78a44e |
children | d813132ea361 |
files | mercurial/templater.py |
diffstat | 1 files changed, 3 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templater.py Sun Apr 10 17:23:09 2016 +0900 +++ b/mercurial/templater.py Sun Apr 03 13:23:40 2016 +0900 @@ -247,11 +247,8 @@ def prettyformat(tree): return parser.prettyformat(tree, ('integer', 'string', 'symbol')) -def compiletemplate(tmpl, context): - """Parse and compile template string to (func, data) pair""" - return compileexp(parse(tmpl), context, methods) - def compileexp(exp, context, curmethods): + """Compile parsed template tree to (func, data) pair""" t = exp[0] if t in curmethods: return curmethods[t](exp, context) @@ -955,7 +952,8 @@ # put poison to cut recursion while compiling 't' self._cache[t] = (_runrecursivesymbol, t) try: - self._cache[t] = compiletemplate(self._loader(t), self) + x = parse(self._loader(t)) + self._cache[t] = compileexp(x, self, methods) except: # re-raises del self._cache[t] raise