diff mercurial/templater.py @ 36992:de117f579431

templater: factor out helper that renders named template as string This is quite common in non-web templating, and **kwargs expansion is annoying because of the unicode-ness of Python3.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 16 Mar 2018 21:24:12 +0900
parents 317382151ac3
children a5311d7f4af8
line wrap: on
line diff
--- a/mercurial/templater.py	Sat Mar 17 11:23:04 2018 +0900
+++ b/mercurial/templater.py	Fri Mar 16 21:24:12 2018 +0900
@@ -725,8 +725,12 @@
 
     def renderdefault(self, mapping):
         """Render the default unnamed template and return result as string"""
+        return self.render('', mapping)
+
+    def render(self, t, mapping):
+        """Render the specified named template and return result as string"""
         mapping = pycompat.strkwargs(mapping)
-        return templateutil.stringify(self('', **mapping))
+        return templateutil.stringify(self(t, **mapping))
 
     def __call__(self, t, **mapping):
         mapping = pycompat.byteskwargs(mapping)