mercurial/templatefilters.py
changeset 8360 acc202b71619
parent 8234 27dbe534397b
child 8389 4b798b100c32
--- a/mercurial/templatefilters.py	Tue May 12 10:57:55 2009 +0200
+++ b/mercurial/templatefilters.py	Tue May 12 12:04:05 2009 +0200
@@ -8,6 +8,12 @@
 import cgi, re, os, time, urllib, textwrap
 import util, templater, encoding
 
+def stringify(thing):
+    '''turn nested template iterator into string.'''
+    if hasattr(thing, '__iter__') and not isinstance(thing, str):
+        return "".join([stringify(t) for t in thing if t is not None])
+    return str(thing)
+
 agescales = [("second", 1),
              ("minute", 60),
              ("hour", 3600),
@@ -194,7 +200,7 @@
     "rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2"),
     "short": lambda x: x[:12],
     "shortdate": util.shortdate,
-    "stringify": templater.stringify,
+    "stringify": stringify,
     "strip": lambda x: x.strip(),
     "urlescape": lambda x: urllib.quote(x),
     "user": lambda x: util.shortuser(x),