Strip Whitespace Middleware

2006-07-27 Thread Doug Van Horn
I don't know if anyone will find this useful, but I thought I'd throw it out there. I wrote a little Middleware class to strip trailing and leading whitespace from a response: import re class StripWhitespaceMiddleware: """ Strips leading and trailing whitespace from response content.

Re: Strip Whitespace Middleware

2006-07-28 Thread Adrian Holovaty
On 7/27/06, Doug Van Horn <[EMAIL PROTECTED]> wrote: > I don't know if anyone will find this useful, but I thought I'd throw > it out there. > > I wrote a little Middleware class to strip trailing and leading > whitespace from a response: Hey Doug, Thanks for contributing this! If you could, pos

Re: Strip Whitespace Middleware

2006-07-31 Thread Will McCutchen
Doug Van Horn wrote: > I wrote a little Middleware class to strip trailing and leading > whitespace from a response: I may be misunderstanding something, but doesn't your middleware actually leave whitespace at the beginning and end of the response? If response.content = '\n\n\nHello.\n\n' it is

Re: Strip Whitespace Middleware

2006-07-31 Thread Doug Van Horn
The intent is primarily to remove extra non-meaningful lines and indents from the response. As an example: {% for foo in foo_list %} {{ foo }} {% endfor %} yields before middleware: biz baz buz and after middleware: biz baz buz It's nothing special, and if I've m

Re: Strip Whitespace Middleware

2006-08-01 Thread Will McCutchen
Doug Van Horn wrote: > Hopefully that makes the intent more clear. Yes, much more clear! For some reason, I thought you were only concerned with whitespace at the beginning and end of the response. Sorry for the trouble! Will. --~--~-~--~~~---~--~~ You receive

Re: Strip Whitespace Middleware

2006-08-01 Thread Gary Wilson
I never really liked how the templating system leaves all those newlines. This middleware is cool, but it would really be nice if the templating system could collapse the lines that only contain one or more evaluating-to-nothing template tags. Thoughts on a possible implementation: What if an e

Re: Strip Whitespace Middleware

2006-08-02 Thread Malcolm Tredinnick
On Tue, 2006-08-01 at 22:53 -0700, Gary Wilson wrote: > I never really liked how the templating system leaves all those > newlines. This middleware is cool, but it would really be nice if the > templating system could collapse the lines that only contain one or > more evaluating-to-nothing templa

Re: Strip Whitespace Middleware

2006-08-02 Thread Nebojša Đorđević
On 28 Jul 2006, at 17:41, Adrian Holovaty wrote: On 7/27/06, Doug Van Horn <[EMAIL PROTECTED]> wrote: I don't know if anyone will find this useful, but I thought I'd throw it out there. I wrote a little Middleware class to strip trailing and leading whitespace from a response: Hey Doug, T

Re: Strip Whitespace Middleware

2006-08-02 Thread Steven Armstrong
On 08/02/06 09:09, Malcolm Tredinnick wrote: [...] > My motivation here was having to debug an email generation template > yesterday that was like a train wreck with all the template tags jammed > together to avoid spurious blank lines. It's going to be a few more days > before I can work on this

Re: Strip Whitespace Middleware

2006-08-02 Thread Ian Holsman
Hi Doug.you have to be careful when striping out whitespace, as sometimes it holds "value"stuff like _javascript_ and 'pre' tags shouldn't have whitespace stripped as you might change the look/behavior of the page.regardsIanOn 01/08/2006, at 1:43 AM, Doug Van Horn wrote:The intent is primarily to r

Re: Strip Whitespace Middleware

2006-08-02 Thread Jacob Kaplan-Moss
Howdy guys -- Just out of curiosity, have you tried using the {% spaceless %} tag? What's it missing that you've needed to use middleware for? (see http://www.djangoproject.com/documentation/templates/#spaceless) Jacob --~--~-~--~~~---~--~~ You received this m

Re: Strip Whitespace Middleware

2006-08-02 Thread gabor
Jacob Kaplan-Moss wrote: > Howdy guys -- > > Just out of curiosity, have you tried using the {% spaceless %} tag? > What's it missing that you've needed to use middleware for? > > (see http://www.djangoproject.com/documentation/templates/#spaceless) > while talking about {% spaceless %}