diff mercurial/templatefilters.py @ 37224:54355c243042

templatefilters: allow declaration of input data type Currently filters take an unwrapped value, which should have no hybrid magic but actually it does because stringify() relies on it. The 'intype' allows us to pre-process the magic by .e.g. evalstring() keeping filter functions as simple as they are now. stringify() is ported as an example. More follow.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 18 Mar 2018 15:14:58 +0900
parents fb7140f1d09d
children 08e042f0a67c
line wrap: on
line diff
--- a/mercurial/templatefilters.py	Mon Mar 19 20:39:06 2018 +0900
+++ b/mercurial/templatefilters.py	Sun Mar 18 15:14:58 2018 +0900
@@ -354,12 +354,12 @@
 def stringescape(text):
     return stringutil.escapestr(text)
 
-@templatefilter('stringify')
+@templatefilter('stringify', intype=bytes)
 def stringify(thing):
     """Any type. Turns the value into text by converting values into
     text and concatenating them.
     """
-    return templateutil.stringify(thing)
+    return thing  # coerced by the intype
 
 @templatefilter('stripdir')
 def stripdir(text):