[stringtemplate-interest] Newbie- if conditional question

Bharani Ellore bharani at ti.com
Fri Mar 27 08:23:19 PDT 2009


I want to print the $bo.label$ if there atleast one item in the sublist 
$bo.sourceWire$. Is there a different way to achieve this?

Thanks.
-Bharani


Sam Barnett-Cormack wrote:
> Bharani Ellore wrote:
>> I have the code in my template.st
>>
>> $outputs: { bo |
>>
>>        $if(length(strip(bo.sourceWire)))$
>>
>>             $bo.label$ zzz
>>
>>         $endif$
>>
>> }$
>>
>>
>> where bo.sourceWire is a <list>. Basically I was to print the label 
>> if the itemList has atleast one string. But somehow it is printing 
>> all the items in $bo$ even though some of them are empty lists.
>>
>> This expression does print number ranging from 0-9. So I know all 
>> item should not be printed.
>> $length(strip(bo.sourceWire))$
>>
>>
>> What am I doing wrong? Any help?
>
> Based on my own first reading of the docs, today, ISTR that $if$ only 
> checks for null or boolean false, not zero, to count as "not" doing it.
>


More information about the stringtemplate-interest mailing list