Re: help on loop variables

Tim Arnold <[email protected]> Thu, 30 Jun 2011 15:55:15 -0400
Newsgroups gmane.comp.python.cheetah
Message-ID <[email protected]>
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
>> =A0<tr>
>> =A0#for $cell in $row
>> =A0 =A0#if $varExists('cell.isHeader') and $cell.isHeader
>> =A0 =A0<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">
>> =A0 =A0<th tal:condition=3D"cell/isHeader"
>> =A0 =A0 =A0 =A0 =A0 tal:attributes=3D"style cell/style/inline;
>> =A0 =A0 =A0 =A0 =A0 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 valuabl=
e.
>> 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
>
>

---------------------------------------------------------------------------=
---
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