##// END OF EJS Templates
templater: take cStringIO out of indent
Matt Mackall -
r3635:7af1f54c default
parent child Browse files
Show More
@@ -256,16 +256,17 b' def shortdate(date):'
256
256
257 def indent(text, prefix):
257 def indent(text, prefix):
258 '''indent each non-empty line of text after first with prefix.'''
258 '''indent each non-empty line of text after first with prefix.'''
259 fp = cStringIO.StringIO()
260 lines = text.splitlines()
259 lines = text.splitlines()
261 num_lines = len(lines)
260 num_lines = len(lines)
262 for i in xrange(num_lines):
261 def indenter():
263 l = lines[i]
262 for i in xrange(num_lines):
264 if i and l.strip(): fp.write(prefix)
263 l = lines[i]
265 fp.write(l)
264 if i and l.strip():
266 if i < num_lines - 1 or text.endswith('\n'):
265 yield prefix
267 fp.write('\n')
266 yield l
268 return fp.getvalue()
267 if i < num_lines - 1 or text.endswith('\n'):
268 yield '\n'
269 return "".join(indenter())
269
270
270 common_filters = {
271 common_filters = {
271 "addbreaks": nl2br,
272 "addbreaks": nl2br,
General Comments 0
You need to be logged in to leave comments. Login now