diff mercurial/templater.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 af854b1b36f8
children 11c0bb4ccc76
line wrap: on
line diff
--- a/mercurial/templater.py	Wed Jun 14 20:56:34 2017 -0400
+++ b/mercurial/templater.py	Sat Apr 22 19:56:47 2017 +0900
@@ -1298,6 +1298,10 @@
                               (self.map[t][1], inst.args[1]))
         return self.cache[t]
 
+    def render(self, mapping):
+        """Render the default unnamed template and return result as string"""
+        return stringify(self('', **mapping))
+
     def __call__(self, t, **mapping):
         ttype = t in self.map and self.map[t][0] or 'default'
         if ttype not in self.ecache: