On Friday, March 18, 2011 11:47:50 AM UTC-4, metaperl wrote:
>
>
>
> On Fri, Mar 18, 2011 at 11:32 AM, Massimo Di Pierro <[email protected]
> > wrote:
>
>>
>>
>> On Mar 18, 8:54 am, Terrence Brannon <[email protected]> wrote:
>> > I dont think the HTML created with
>> > web2py's template system is well-formed is it?
>> >
>> > <table>
>> > {{ for row: in rows }} <---- breaks well-formedness?
>> > <tr>
>> > ...
>> > </tr>
>>
>> Not sure I understand. Are you referring to the extra new line?
>>
>
> No, I was guessing it is not allowed for plain-text to be between <table>
> and <tr> in well-formed HTML, but I could be wrong ( and probably should've
> used HTML tidy to figure it out :)
>
The template code to which you are pointing does not actually generate any
HTML at the point of the {{ for row in rows:}} Python code (i.e., between
the table and tr tags). That is simply a Python statement that begins a for
loop, which loops over the subsequent lines (i.e., the lines from <tr> to
</tr>) -- the loop creates a table row for each row in rows (there should be
a {{pass}} statement at the end to indicate the scope of the loop). The
template system is not inserting text in every place where you see {{ }}. It
only inserts something if preceded by an '=', such as
{{=var_from_controller}}, or when response.write is called explicitly. Does
that make sense? Read ch. 5 for more details:
http://web2py.com/book/default/chapter/05
Anthony