[stringtemplate-interest] Newbie- if conditional question
Bharani Ellore
bharani at ti.com
Fri Mar 27 13:53:56 PDT 2009
This works. Thanks a lot Sam.
-Bharani
Sam Harwell wrote:
> At least in the latest version, $if(bo.sourceWire)$ is only true if the
> list contains at least one item.
>
> Sam
>
> -----Original Message-----
> From: stringtemplate-interest-bounces at antlr.org
> [mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of Bharani
> Ellore
> Sent: Friday, March 27, 2009 10:23 AM
> To: Sam Barnett-Cormack
> Cc: stringtemplate-interest at antlr.org
> Subject: Re: [stringtemplate-interest] Newbie- if conditional question
>
> 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.
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20090327/914ff437/attachment.html
More information about the stringtemplate-interest
mailing list