[stringtemplate-interest] Filtering a list
Terence Parr
parrt at cs.usfca.edu
Sun Apr 22 19:12:36 PDT 2007
Awesome! Gotta love those anonymous {...} blocks. :)
Ter
On Apr 22, 2007, at 6:52 PM, Bogdan Calmac wrote:
> Hi Ter,
>
> Yes, you're right, that works fine.
>
> Thanks,
>
> Bogdan.
>
> On 4/13/07, Terence Parr <parrt at cs.usfca.edu> wrote:
>>
>> On Apr 13, 2007, at 7:33 AM, Bogdan Calmac wrote:
>>
>>> Hi Ter,
>>>
>>> Thanks, but actually I need the oposite here, to force a null
>>> instead
>>> of empty string.
>>
>> Ah. then you need to set null not "" I'm afraid.
>>
>>> Again, in my example I have a list of persons with a "smart" boolean
>>> field and I want to print a comma separated list of the smart
>>> people.
>>> This requires to filter out those persons which are not "smart",
>>> which
>>> means returning null from an <if> expression so that I don't get
>>> empty
>>> slots in the list.
>>
>> Oh, that's easy:
>>
>> $names{n | $if(n.smart)$$n$$endif$}; separator=", "$
>>
>> Let me know if that works for you. Assuming names i s alist of Name
>> objects or whatever.
>>
>> Ter
>>
>>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list