Mercurial > public > mercurial-scm > hg-stable
diff mercurial/formatter.py @ 32891:2ecce24dfcd3
templater: add simple interface for unnamed template (API)
This provides a simpler API for callers which don't need full templating
stack. Instead of storing the given template as the name specified by topic,
use '' as the default template to be rendered.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 22 Apr 2017 19:56:47 +0900 |
parents | 883adaea9e80 |
children | c8f2cf18b82e |
line wrap: on
line diff
--- a/mercurial/formatter.py Wed Jun 14 20:56:34 2017 -0400 +++ b/mercurial/formatter.py Sat Apr 22 19:56:47 2017 +0900 @@ -431,10 +431,13 @@ assert not (spec.tmpl and spec.mapfile) if spec.mapfile: return templater.templater.frommapfile(spec.mapfile, cache=cache) - return maketemplater(ui, spec.ref, spec.tmpl, cache=cache) + return _maketemplater(ui, spec.ref, spec.tmpl, cache=cache) -def maketemplater(ui, topic, tmpl, cache=None): +def maketemplater(ui, tmpl, cache=None): """Create a templater from a string template 'tmpl'""" + return _maketemplater(ui, '', tmpl, cache=cache) + +def _maketemplater(ui, topic, tmpl, cache=None): aliases = ui.configitems('templatealias') t = templater.templater(cache=cache, aliases=aliases) if tmpl: