Re: [Karrigell-main] Indentation in PIH
Brought to you by:
quentel
From: Pierre Q. <que...@wa...> - 2003-05-12 19:44:31
|
Yes, if you use this tag you must follow Python indentation rules ; by = the way, I have renamed it <indent> and </indent> instead of <%% and %%> But the use of <indent> is optional. If you don't use it, the rules = remain as follow : - indentation starts from 0 - it is incremented by one every time a Python chunk (between <% %>) = ends with a colon - it is decremented by one with <% end %> (difference with version 1.1 = of Karrigell where it came back to zero) So for a multiplication table you can choose between two versions : 1 - version without <indent"> -------------------------------- <table border=3D1> <% for i in ['h']+range(10): %> <tr> <% for j in ['h']+range(10): %> <% if i!=3D'h' and j!=3D'h': %> <td><%=3D i*j %></td> <% end %> <% elif i!=3D'h': %> <th><%=3D i %></th> <% end %> <% elif j!=3D'h': %> <th><%=3D j %></th> <% end %> <% else: %> <td>*</td> <% end %> <% end %> </tr> <% end %> </table> -------------------------------- (in this example, everything could be unindented, or indented in a = different way) 2 - version with <indent> --------------------------------- <table border=3D1> <indent> <% for i in ['h']+range(10): %> <tr> <% for j in ['h']+range(10): %> <% if i!=3D'h' and j!=3D'h': %> <td><%=3D i*j %></td> <% elif i!=3D'h': %> <th><%=3D i %></th> <% elif j!=3D'h': %> <th><%=3D j %></th> <% else: %> <td>*</td> </tr> </indent> </table> --------------------------------- It is perhaps more readable, and avoids the use of many <% end %>. I'm = aware that it has its drawbacks, for instance all consecutive HTML line *must* have the same indentation, you can't write : <indent> <tr> <td>A cell</td> </tr> </indent> A more complete explanation is on CVS http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/karrigell/Karri= gell/doc/en/pythoninsidehtml.htm?rev=3D1.4 Also see the last version of the PythonInsideHTML.py module on the CVS, = it includes a GUI application which shows how PIH files are parsed All this remains open to discussion... Pierre ----- Original Message -----=20 From: "Gabriele Giorgetti" <gab...@te...> To: "Pierre Quentel" <que...@wa...> Sent: Monday, May 12, 2003 10:51 AM Subject: Re: [Karrigell-main] Indentation in PIH > Pierre Quentel wrote: > > > I've been discussing identation issues with Karrigell users and = would > > like to have an opinion on a better way to deal with it > > > > I propose to introduce a new couple of tags (say <%% and %%>) which > > mean : inside these tags, all indentation must be taken into account > > to produce the Python script, even for HTML parts (so there is no = need > > for <% end %> tags to decrement the indentation) > > > > For instance : > > > > <!-- start using indentation --> > > <%% > > <% for i in .... : %> > > <tr> > > <% if .... : %> > > <td> blabla </td> > > <% elif : %> > > <td> xoxox </td> > > </tr> > > %%> > > <!-- indentation off --> > > <table> > > <tr> > > <td>A cell</td> > > <tr> > > </table> > > Any feedback on this point would be helpful > > Pierre > > Hi Pierre, I'm not sure about what are you trying to accomplish = here... > Let's say that if I don't indent html code correctly inside "<%%", = "%%>" > tags (which can be quite confusing IMHO), Karrigell will complain ? > > PS: The Goadec Sisters mp3 is just scaring :-) > > > |