comparison mercurial/templatefilters.py @ 12371:48a4acd1ccf1

templater: add hex filter.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Wed, 22 Sep 2010 00:14:57 +0200
parents 0bedf3a2062a
children 57150dc5a9c7
comparison
equal deleted inserted replaced
12370:f98010f57a5e 12371:48a4acd1ccf1
4 # 4 #
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 import cgi, re, os, time, urllib 8 import cgi, re, os, time, urllib
9 import util, encoding 9 import encoding, node, util
10 10
11 def stringify(thing): 11 def stringify(thing):
12 '''turn nested template iterator into string.''' 12 '''turn nested template iterator into string.'''
13 if hasattr(thing, '__iter__') and not isinstance(thing, str): 13 if hasattr(thing, '__iter__') and not isinstance(thing, str):
14 return "".join([stringify(t) for t in thing if t is not None]) 14 return "".join([stringify(t) for t in thing if t is not None])
214 "obfuscate": obfuscate, 214 "obfuscate": obfuscate,
215 "permissions": permissions, 215 "permissions": permissions,
216 "person": person, 216 "person": person,
217 "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2"), 217 "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2"),
218 "rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2"), 218 "rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2"),
219 "hex": node.hex,
219 "short": lambda x: x[:12], 220 "short": lambda x: x[:12],
220 "shortdate": util.shortdate, 221 "shortdate": util.shortdate,
221 "stringify": stringify, 222 "stringify": stringify,
222 "strip": lambda x: x.strip(), 223 "strip": lambda x: x.strip(),
223 "urlescape": lambda x: urllib.quote(x), 224 "urlescape": lambda x: urllib.quote(x),