Re: [Myghty-users] is this a bug?
Brought to you by:
zzzeek
From: michael b. <mi...@my...> - 2004-12-11 02:39:25
|
gvozden - important part of using the % syntax, is that when you create an "indented" area via a % line, you have to "close" the indented area when the scope of the section is done. this is because otherwise the parser has no way of knowing when the indentation you set has completed. when you open an indentation area with a line like "% for a in foo:", the corresponding "closure" is simply a "%" with just a newline (and optional comment): <%method menu trim="both"> <div class="menu"> % for items in files: % for item, subitem in items.iteritems(): <& SELF:menuitem, menuitem=subitem, text=item &> % # close the for inner loop % # close the outer for loop </div> </%method> try that out and see if it fixes your problem. Originally, I really wanted to make Myghty look the way you intuitively did your code, but its not really possible, unless the syntax of the entire template were completely indented including all the HTML, and that would be a mess. the blank % lines are the most minimal method of having the python indentation mixed with non-indented code. On Dec 10, 2004, at 6:33 PM, Gvozden Marinkovic wrote: > I have recursive method call in a menu.myc component: > > <%python scope="global"> > > files = [ > {'Home' : '' > }, > > {'Software' : { > 'Project1':'Path1', > 'Project2':'Path2', > }}, > ] > > </%python> > > <& SELF:menu &> > > <%method menu trim="both"> > <div class="menu"> > % for items in files: > % for item, subitem in items.iteritems(): > <& SELF:menuitem, menuitem=subitem, text=item &> > </div> > </%method> > > <%method menuitem trim="both"> > <%args> > menuitem, > text, > level = 0 > </%args> > % if menuitem.__class__.__name__ == 'str': > <div class="menuitem<% str(level) %>"> > <a href="<& common.myc:site_uri &>/<% "%s" % menuitem %>"> > <% text %> > </a> > </div> > % else: > % for item, subitem in menuitem.iteritems(): > <& SELF:menuitem, menuitem=subitem, text=item, level = level > + 1 &> > </%method> > > > I think that </div> tag after menuitem0 class is bug. Output is: > > html> > > <head> > <title>PlusPlus</title> > <link href="plusplus.css" rel="stylesheet" type="text/css"></link> > </head> > > <body> > > <div id="header" > > <img src="images\logo.jpg"> > </div> > > > <div id="main"> > <table id="main_columns"> > <tr> > <td id="left_column"> > > <div class="menu"> > <div class="menuitem0"> > <a href="http://www.plusplus.co.yu/"> > Home > </a> > </div> > > </div> ************* this one is bug! > > <div class="menuitem1"> > <a href="http://www.plusplus.co.yu/Path1"> > Project1 > </a> > </div> > > <div class="menuitem1"> > <a href="http://www.plusplus.co.yu/Path2"> > Project2 > </a> > </div> > </div> > > > > </td> > <td id="right_column"> > </td> > </tr> > </table> > </div> > <div id="footer"> > </div> > > </body> > > </html> > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real > users. > Discover which products truly live up to the hype. Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > Myghty-users mailing list > Myg...@li... > https://lists.sourceforge.net/lists/listinfo/myghty-users |