yep. as a total offtopic (but related) real-world scenario, in 2013 all the 
cpu power that a server provides can be (and I strongly believe it **must** 
be) used to gzip the page: in such case minifying the HTML has very little 
impact (if no impact at all) in the loading speed of a page.

On Friday, August 2, 2013 8:10:23 PM UTC+2, Anthony wrote:
>
> Every line with a {{...}} (that doesn't start with "=") results in a blank 
> line being written to the view output. To avoid that, you have to move all 
> {{...}} code onto lines that generate output so you don't get any 
> extraneous blank lines. For example, the code generating all the whitespace 
> you identified below looks like this:
>
> </ol>
> {{elif 'content' in globals():}}
> {{=content}}
> {{else:}}
> {{=BEAUTIFY(response._vars)}}
> {{pass}}
>
> {{block right_sidebar}}
>
> To get rid of all the whitespace, you would have to do:
>
> </ol>{{elif 'content' in 
> globals():}}{{=content}}{{else:}}{{=BEAUTIFY(response._vars)}}{{pass}}{{block 
> right_sidebar}}
>
> which is much less readable. I'm not sure if there is an easy way to 
> change how the parser works to produce different output.
>
> Anthony
>
> On Friday, August 2, 2013 1:22:49 PM UTC-4, Mark Finkelstein wrote:
>>
>> Well an example would be the default page that appears in web2py (reached 
>> by, for example, http://127.0.0.1:8000/welcome/default/index), there is 
>> a large amount of spaces in there that needlessly inflate the file; in that 
>> file, for example, there is this:
>>
>> <h3>Hello World</h3>
>>
>>
>> <h4>How did you get here?</h4>
>> <ol>
>>   <li>You are successfully running web2py</li>
>>   <li>You visited the url <a href="/welcome/default/index">
>> /welcome/default/index</a></li>
>>   <li>Which called the function <a href="#">index()</a> located in the 
>> file <a href="/admin/default/peek/welcome/controllers/default.py">
>> web2py/applications/welcome/controllers/default.py</a></li>
>>   <li>The output of the file is a dictionary that was rendered by the 
>> view <a href="/admin/default/peek/welcome/views/default/index.html">
>> web2py/applications/welcome/views/default/index.html</a></li>
>>   <li>You can modify this application and adapt it to your needs</li>
>> </ol>
>>
>>
>>
>>
>>
>>
>>
>>
>>             
>>         </div>
>>
>>
>>         
>>         <div class="span3">
>>
>>
>>
>>
>> You've already answered the question, I just wonder why the renderer 
>> renders in this way by default.
>>
>> On Thursday, August 1, 2013 11:52:20 PM UTC-4, Anthony wrote:
>>>
>>> You could put more template code and HTML onto a single line rather than 
>>> on separate lines, though that will result in less readable/maintainable 
>>> templates. Can you show a specific example of (a) some template code, (b) 
>>> the HTML it generates, and (c) the HTML you would prefer to see instead?
>>>
>>> Anthony
>>>
>>> On Thursday, August 1, 2013 9:23:52 PM UTC-4, Mark Finkelstein wrote:
>>>>
>>>> Sure; instead of calling minify dynamically, which would take extra 
>>>> computation, I was wondering if there was a better way so that the excess 
>>>> spaces do not appear to begin with (by minifying the actual view python 
>>>> file in a way). Also, thanks for being a great help on this forum.
>>>>
>>>> On Thursday, August 1, 2013 9:18:36 PM UTC-4, Anthony wrote:
>>>>>
>>>>> Can you give an example of what you are trying to achieve?
>>>>>
>>>>> On Thursday, August 1, 2013 9:14:41 PM UTC-4, Mark Finkelstein wrote:
>>>>>>
>>>>>> I actually meant minifying the view py file itself to remove the 
>>>>>> spaces where they would have been produced?
>>>>>>
>>>>>> On Thursday, August 1, 2013 6:39:52 PM UTC-4, Anthony wrote:
>>>>>>>
>>>>>>> I think something like:
>>>>>>>
>>>>>>> from gluon.contrib.minify import htmlmin
>>>>>>>
>>>>>>> def myaction():
>>>>>>>     ...
>>>>>>>     return htmlmin.minify(response.render(dict(...)))
>>>>>>>
>>>>>>> Anthony
>>>>>>>
>>>>>>> On Thursday, August 1, 2013 5:57:51 PM UTC-4, Mark Finkelstein wrote:
>>>>>>>>
>>>>>>>> I noticed that as it stands, the html response sent is filled with 
>>>>>>>> spaces due to formatting, I was wondering if there was a way to 
>>>>>>>> 'minify' or 
>>>>>>>> remove all the spaces and compress the view file to decrease the size 
>>>>>>>> of 
>>>>>>>> the response and make it more aesthetically pleasing. Thank you in 
>>>>>>>> advance.
>>>>>>>
>>>>>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to