##// END OF EJS Templates
templater: rename .render(mapping) to .renderdefault(mapping) (API)...
Yuya Nishihara -
r37003:31738215 default
parent child Browse files
Show More
@@ -260,7 +260,7 b' def showstack(ui, repo, displayer):'
260 shortesttmpl = formatter.maketemplater(ui, '{shortest(node, %d)}' % nodelen,
260 shortesttmpl = formatter.maketemplater(ui, '{shortest(node, %d)}' % nodelen,
261 resources=tres)
261 resources=tres)
262 def shortest(ctx):
262 def shortest(ctx):
263 return shortesttmpl.render({'ctx': ctx, 'node': ctx.hex()})
263 return shortesttmpl.renderdefault({'ctx': ctx, 'node': ctx.hex()})
264
264
265 # We write out new heads to aid in DAG awareness and to help with decision
265 # We write out new heads to aid in DAG awareness and to help with decision
266 # making on how the stack should be reconciled with commits made since the
266 # making on how the stack should be reconciled with commits made since the
@@ -907,7 +907,7 b' def rendertemplate(ctx, tmpl, props=None'
907 mapping = {'ctx': ctx, 'revcache': {}}
907 mapping = {'ctx': ctx, 'revcache': {}}
908 if props:
908 if props:
909 mapping.update(props)
909 mapping.update(props)
910 return t.render(mapping)
910 return t.renderdefault(mapping)
911
911
912 def _buildfntemplate(pat, total=None, seqno=None, revwidth=None, pathname=None):
912 def _buildfntemplate(pat, total=None, seqno=None, revwidth=None, pathname=None):
913 r"""Convert old-style filename format string to template string
913 r"""Convert old-style filename format string to template string
@@ -2455,7 +2455,7 b' def debugtemplate(ui, repo, tmpl, **opts'
2455 if revs is None:
2455 if revs is None:
2456 tres = formatter.templateresources(ui, repo)
2456 tres = formatter.templateresources(ui, repo)
2457 t = formatter.maketemplater(ui, tmpl, resources=tres)
2457 t = formatter.maketemplater(ui, tmpl, resources=tres)
2458 ui.write(t.render(props))
2458 ui.write(t.renderdefault(props))
2459 else:
2459 else:
2460 displayer = logcmdutil.maketemplater(ui, repo, tmpl)
2460 displayer = logcmdutil.maketemplater(ui, repo, tmpl)
2461 for r in revs:
2461 for r in revs:
@@ -563,7 +563,7 b' def _formatconflictmarker(ctx, template,'
563 ctx = ctx.p1()
563 ctx = ctx.p1()
564
564
565 props = {'ctx': ctx}
565 props = {'ctx': ctx}
566 templateresult = template.render(props)
566 templateresult = template.renderdefault(props)
567
567
568 label = ('%s:' % label).ljust(pad + 1)
568 label = ('%s:' % label).ljust(pad + 1)
569 mark = '%s %s' % (label, templateresult)
569 mark = '%s %s' % (label, templateresult)
@@ -285,7 +285,7 b' class changesetprinter(object):'
285 t = formatter.maketemplater(self.repo.ui, '{join(obsfate, "\n")}',
285 t = formatter.maketemplater(self.repo.ui, '{join(obsfate, "\n")}',
286 defaults=templatekw.keywords,
286 defaults=templatekw.keywords,
287 resources=tres)
287 resources=tres)
288 obsfate = t.render({'ctx': ctx, 'revcache': {}}).splitlines()
288 obsfate = t.renderdefault({'ctx': ctx, 'revcache': {}}).splitlines()
289
289
290 if obsfate:
290 if obsfate:
291 for obsfateline in obsfate:
291 for obsfateline in obsfate:
@@ -858,7 +858,7 b' def _graphnodeformatter(ui, displayer):'
858 resources=tres)
858 resources=tres)
859 def formatnode(repo, ctx):
859 def formatnode(repo, ctx):
860 props = {'ctx': ctx, 'repo': repo, 'revcache': {}}
860 props = {'ctx': ctx, 'repo': repo, 'revcache': {}}
861 return templ.render(props)
861 return templ.renderdefault(props)
862 return formatnode
862 return formatnode
863
863
864 def displaygraph(ui, repo, dag, displayer, edgefn, getrenamed=None, props=None):
864 def displaygraph(ui, repo, dag, displayer, edgefn, getrenamed=None, props=None):
@@ -723,7 +723,7 b' class templater(object):'
723 raise IOError(inst.args[0], encoding.strfromlocal(reason))
723 raise IOError(inst.args[0], encoding.strfromlocal(reason))
724 return self.cache[t]
724 return self.cache[t]
725
725
726 def render(self, mapping):
726 def renderdefault(self, mapping):
727 """Render the default unnamed template and return result as string"""
727 """Render the default unnamed template and return result as string"""
728 mapping = pycompat.strkwargs(mapping)
728 mapping = pycompat.strkwargs(mapping)
729 return templateutil.stringify(self('', **mapping))
729 return templateutil.stringify(self('', **mapping))
General Comments 0
You need to be logged in to leave comments. Login now