[stringtemplate-interest] Filtering a list

Terence Parr parrt at cs.usfca.edu
Fri Apr 13 10:24:48 PDT 2007


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



More information about the stringtemplate-interest mailing list