On Dec 15, 2009, at 12:08 PM, Alex Fanjul wrote:
> Hello Kbochert, it seems you found out a way to make cleaner output, do
> you get it working automatically? (ie. with out manual action for output
> clean process)
> I'm thinking in alway pass dictionaris throught filter function so
> instead of return dict we'd return filter(dict) but I'm not sure if it
> would be right.
> Could you give me the steps or snippet example to achieve this?
>
> Finally, did you find any disadventages doing this? errors, slower
> speed, etc...
I think it might be most useful to filter the entire page content, after it's
composed, but before it's delivered. Say a filter function, by default None, in
response, that gets called just before delivering the page, if the content-type
is appropriate.
>
> Thanks a lot,
> Alex F
>
> El 15/12/2009 17:13, kbochert escribió:
>> Jonathon wrote:
>>
>>> 2x seems like an awful lot, since a newline is only one byte. Are you sure?
>>>
>> The output typically has multiple leading spaces on those blank
>> lines, presumably driven by the indenting of the original html.
>>
>> DenesL wrote:
>>
>>> Do you want you view or your final output to be legible and
>>> aesthetically pleasing according to some subjective human standard?.
>>>
>> Absolutely!
>> For instance, I'm currently looking for a designer to style my site.
>> The first thing I do is surf to their home page and look at its source
>> code!
>> If I'm evangelizing web2py to colleagues, clean output helps. (makes
>> me prouder of my work, at least)
>>
>>
>> I tried massimos' code snippet
>> def filter(d):
>> import re
>> if isinstance(d,dict):
>> return re.compile('\n\n').sub('\n',response.render(d))
>> return d
>> response._caller=filter
>>
>> It failed, generating pages with a single line of html "<function
>> index at 0x01A04C70>"
>> -- but --
>>
>> def filter(d):
>> import re
>> if isinstance(d,dict):
>> return re.compile('\n\s\s+\n').sub('\n',response.render(d))
>> return re.compile('\n\s\s+\n').sub('\n',response.render(d()))
>> response._caller=filter
>>
>> worked !beautifully! When I take care to write the template cleanly,
>> the rendering is also clean.
>>
>> This makes a distinction between empty lines (with no characters), and
>> blank lines (containing only whitespace chars).
>> blank lines are removed, empty lines are not. (whitespace matters!)
>>
>>
>> It would be nice if web2py could make this its default rendering
>> behavior.
>>
>> Are there other issues than<pre> blocks?
>>
>>
>> Karl
>>
>>
>>
>> --
>>
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/web2py?hl=en.
>>
>>
>>
>>
>
> --
> Alejandro Fanjul Fdez.
> [email protected]
> www.mhproject.org
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/web2py?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.