##// END OF EJS Templates
templater: factor out function that creates templater from string template...
Yuya Nishihara -
r28955:78759f78 default
parent child Browse files
Show More
@@ -1492,9 +1492,9 b' class changeset_templater(changeset_prin'
1492 1492 self.t = templater.templater.frommapfile(mapfile, filters=filters,
1493 1493 cache=defaulttempl)
1494 1494 else:
1495 self.t = templater.templater(filters=filters, cache=defaulttempl)
1496 if tmpl:
1497 self.t.cache['changeset'] = tmpl
1495 self.t = formatter.maketemplater(ui, 'changeset', tmpl,
1496 filters=filters,
1497 cache=defaulttempl)
1498 1498
1499 1499 self.cache = {}
1500 1500
@@ -46,6 +46,7 b' from . import ('
46 46 exchange,
47 47 extensions,
48 48 fileset,
49 formatter,
49 50 graphmod,
50 51 hbisect,
51 52 help,
@@ -3681,8 +3682,7 b' def debugtemplate(ui, repo, tmpl, **opts'
3681 3682 mapfile = None
3682 3683 if revs is None:
3683 3684 k = 'debugtemplate'
3684 t = templater.templater()
3685 t.cache[k] = tmpl
3685 t = formatter.maketemplater(ui, k, tmpl)
3686 3686 ui.write(templater.stringify(t(k, **props)))
3687 3687 else:
3688 3688 displayer = cmdutil.changeset_templater(ui, repo, None, opts, tmpl,
@@ -17,6 +17,7 b' from .node import nullid, short'
17 17
18 18 from . import (
19 19 error,
20 formatter,
20 21 match,
21 22 scmutil,
22 23 simplemerge,
@@ -526,7 +527,7 b' def _formatlabels(repo, fcd, fco, fca, l'
526 527
527 528 ui = repo.ui
528 529 template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker)
529 tmpl = templater.templater(cache={'conflictmarker': template})
530 tmpl = formatter.maketemplater(ui, 'conflictmarker', template)
530 531
531 532 pad = max(len(l) for l in labels)
532 533
@@ -193,7 +193,11 b' def gettemplater(ui, topic, spec):'
193 193 assert not (tmpl and mapfile)
194 194 if mapfile:
195 195 return templater.templater.frommapfile(mapfile)
196 t = templater.templater()
196 return maketemplater(ui, topic, tmpl)
197
198 def maketemplater(ui, topic, tmpl, filters=None, cache=None):
199 """Create a templater from a string template 'tmpl'"""
200 t = templater.templater(filters=filters, cache=cache)
197 201 if tmpl:
198 202 t.cache[topic] = tmpl
199 203 return t
General Comments 0
You need to be logged in to leave comments. Login now