Re: help on loop variables
James Abbatiello <[email protected]> Tue, 28 Jun 2011 21:55:36 -0400
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
--===============3579297882632440563==
Content-Type: multipart/alternative; boundary=20cf302d49be9dce0204a6d014b8
--20cf302d49be9dce0204a6d014b8
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable
Try
#if $cell.get('isHeader', False)
or
#if $cell.has_key('isHeader') and $cell.isHeader
--=20
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 want
> 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 makes
> 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
>
--20cf302d49be9dce0204a6d014b8
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: quoted-printable
Try<br><br>#if $cell.get('isHeader', False)<br><br>or<br><br>#if $c=
ell.has_key('isHeader') and $cell.isHeader<br><br>-- <br>James Abba=
tiello<br><br><br><div class=3D"gmail_quote">On Tue, Jun 28, 2011 at 2:53 P=
M, Tim Arnold <span dir=3D"ltr"><<a href=3D"mailto:[email protected]=
">[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;">As far as I can tell, it is impossible to u=
se $varExists() inside a<br>
loop variable. So I'm asking for help on how to re-think my situation.<=
br>
<br>
First, here's what will not work in Cheetah. varExists is always 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 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>
All of the data generated in your IT infrastructure is seriously valuable.<=
br>
Why? It contains a definitive record of application performance, security<b=
r>
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">http://p.sf=
.net/sfu/splunk-d2d-c2</a><br>
_______________________________________________<br>
Cheetahtemplate-discuss mailing list<br>
<a href=3D"mailto:[email protected]">Cheetahtem=
[email protected]</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-dis=
cuss" target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/cheeta=
htemplate-discuss</a><br>
</blockquote></div><br>
--20cf302d49be9dce0204a6d014b8--
--===============3579297882632440563==
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
--===============3579297882632440563==
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
--===============3579297882632440563==--