Re: help on loop variables
James Abbatiello <[email protected]> Thu, 30 Jun 2011 19:21:34 -0400
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
--===============2968667642243374441== Content-Type: multipart/alternative; boundary=20cf3011dcc16f585104a6f62947 --20cf3011dcc16f585104a6f62947 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Odd, it worked for me in my tests. What is the type of $cell in your template? Can you provide a minimal complete example? --=20 James Abbatiello On Thu, Jun 30, 2011 at 3:55 PM, Tim Arnold <[email protected]> wrote: > thanks for the help, but that doesn't work either. (not even getVar). > I think it's impossible to do this with Cheetah. > I'm rewriting this particular template in simpletal. > > thanks, > --Tim > On Tue, Jun 28, 2011 at 9:55 PM, James Abbatiello <[email protected]> > wrote: > > Try > > > > #if $cell.get('isHeader', False) > > > > or > > > > #if $cell.has_key('isHeader') and $cell.isHeader > > > > -- > > James Abbatiello > > > > > > On Tue, Jun 28, 2011 at 2:53 PM, Tim Arnold <[email protected]> > wrote: > >> > >> As far as I can tell, it is impossible to use $varExists() inside a > >> loop variable. So I'm asking for help on how to re-think my situation. > >> > >> First, here's what will not work in Cheetah. varExists is always false= : > >> #for $row in $here > >> <tr> > >> #for $cell in $row > >> #if $varExists('cell.isHeader') and $cell.isHeader > >> <th style=3D"$cell.style.inline">${cell}</th> > >> > >> Second, here is a similar template, but written in SimpleTal that does > >> work: > >> <metal:block tal:repeat=3D"cell row"> > >> <th tal:condition=3D"cell/isHeader" > >> tal:attributes=3D"style cell/style/inline; > >> tal:content=3D"cell"></th> > >> </metal:block> > >> > >> I have some table cells with a varying suite of attributes; where > >> those attributes exist I want to use them, and of course I don=92t wan= t > >> to get an error when trying to use a non-existent attribute. > >> > >> Finally, my question: > >> is there any way to accomplish this with a Cheetah template? > >> > >> thanks, > >> --Tim Arnold > >> > >> > >> > -------------------------------------------------------------------------= ----- > >> All of the data generated in your IT infrastructure is seriously > valuable. > >> Why? It contains a definitive record of application performance, > security > >> threats, fraudulent activity, and more. Splunk takes this data and mak= es > >> sense of it. IT sense. And common sense. > >> http://p.sf.net/sfu/splunk-d2d-c2 > >> _______________________________________________ > >> Cheetahtemplate-discuss mailing list > >> [email protected] > >> https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss > > > > > --20cf3011dcc16f585104a6f62947 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Odd, it worked for me in my tests.=A0 What is the type of $cell in your tem= plate?=A0 Can you provide a minimal complete example?<br><br>-- <br>James A= bbatiello<br><br><br><div class=3D"gmail_quote">On Thu, Jun 30, 2011 at 3:5= 5 PM, Tim Arnold <span dir=3D"ltr"><<a href=3D"mailto:jtim.arnold@gmail.= com">[email protected]</a>></span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex;">thanks for the help, but that doesn't w= ork either. (not even getVar).<br> I think it's impossible to do this with Cheetah.<br> I'm rewriting this particular template in simpletal.<br> <br> thanks,<br> <font color=3D"#888888">--Tim<br> </font><div><div></div><div class=3D"h5">On Tue, Jun 28, 2011 at 9:55 PM, J= ames Abbatiello <<a href=3D"mailto:[email protected]">[email protected]</a= >> wrote:<br> > Try<br> ><br> > #if $cell.get('isHeader', False)<br> ><br> > or<br> ><br> > #if $cell.has_key('isHeader') and $cell.isHeader<br> ><br> > --<br> > James Abbatiello<br> ><br> ><br> > On Tue, Jun 28, 2011 at 2:53 PM, Tim Arnold <<a href=3D"mailto:jtim= [email protected]">[email protected]</a>> wrote:<br> >><br> >> As far as I can tell, it is impossible to use $varExists() inside = a<br> >> loop variable. So I'm asking for help on how to re-think my si= tuation.<br> >><br> >> First, here's what will not work in Cheetah. varExists is alwa= ys false:<br> >> #for $row in $here<br> >> =A0<tr><br> >> =A0#for $cell in $row<br> >> =A0 =A0#if $varExists('cell.isHeader') and $cell.isHeader<= br> >> =A0 =A0<th style=3D"$cell.style.inline">${cell}<= ;/th><br> >><br> >> Second, here is a similar template, but written in SimpleTal that = does<br> >> work:<br> >> <metal:block tal:repeat=3D"cell row"><br> >> =A0 =A0<th tal:condition=3D"cell/isHeader"<br> >> =A0 =A0 =A0 =A0 =A0 tal:attributes=3D"style cell/style/inline= ;<br> >> =A0 =A0 =A0 =A0 =A0 tal:content=3D"cell"></th><= br> >> </metal:block><br> >><br> >> I have some table cells with a varying suite of attributes; where<= br> >> those attributes exist I want to use them, and of course I don=92t= want<br> >> to get an error when trying to use a non-existent attribute.<br> >><br> >> Finally, my question:<br> >> is there any way to accomplish this with a Cheetah template?<br> >><br> >> thanks,<br> >> --Tim Arnold<br> >><br> >><br> >> ------------------------------------------------------------------= ------------<br> >> All of the data generated in your IT infrastructure is seriously v= aluable.<br> >> Why? It contains a definitive record of application performance, s= ecurity<br> >> threats, fraudulent activity, and more. Splunk takes this data and= makes<br> >> sense of it. IT sense. And common sense.<br> >> <a href=3D"http://p.sf.net/sfu/splunk-d2d-c2" target=3D"_blank">ht= tp://p.sf.net/sfu/splunk-d2d-c2</a><br> >> _______________________________________________<br> >> Cheetahtemplate-discuss mailing list<br> >> <a href=3D"mailto:[email protected]">C= [email protected]</a><br> >> <a href=3D"https://lists.sourceforge.net/lists/listinfo/cheetahtem= plate-discuss" target=3D"_blank">https://lists.sourceforge.net/lists/listin= fo/cheetahtemplate-discuss</a><br> ><br> ><br> </div></div></blockquote></div><br> --20cf3011dcc16f585104a6f62947-- --===============2968667642243374441== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 --===============2968667642243374441== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Cheetahtemplate-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss --===============2968667642243374441==--