Changes between Version 3 and Version 4 of StripWhitespaceMiddleware
- Timestamp:
- May 31, 2011, 12:59:49 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
StripWhitespaceMiddleware
v3 v4 6 6 Tightens up response content by removed superflous line breaks and whitespace. 7 7 By Doug Van Horn 8 9 ---- 10 v1.1 - 31st May 2011 11 Cal Leeming [Simplicity Media Ltd] 12 Modified regex to strip leading/trailing white space from every line, not just those with blank \n. 13 --- 14 TODO: Ensure whitespace isn't stripped from within <pre> or <code> or <textarea> tags. 15 --- 8 16 """ 9 17 … … 16 24 17 25 def __init__(self): 18 self.whitespace = re.compile(' \s*\n')26 self.whitespace = re.compile('^\s+|\s+$', re.MULTILINE) 19 27 20 28 def process_response(self, request, response): … … 25 33 else: 26 34 return response 35 27 36 }}}