[stringtemplate-interest] suggestion for a new option 'empty='
Terence Parr
parrt at cs.usfca.edu
Mon Dec 8 10:56:24 PST 2008
added
http://www.antlr.org:8888/browse/ST-47
Thanks,
ter
On Nov 26, 2008, at 11:57 AM, Jasper Roel wrote:
> After a small discussion with Terence about this, here is a (new?)
> idea for StringTemplate;
>
> In addition to the 'null=""' option for any given variable, it might
> be (is) useful to have a 'empty=' parameter.
>
> Currently we can use lazy eval for this, as the following example:
> $if( (msg.subject) )$
> $msg.subject$
> $else$
> [no subject]
> $endif$
>
> OR (if it's just a null check):
>
> $msg.subject;null="[no subject]"$
>
> It would be nice to have a way to say:
>
> $msg.subject;null="[null value]";empty="[empty value]"$
>
> It's debatable if the 'empty=' parameter should also check for null
> pointers. If it does, we can skip the 'null=' part,
> and end up with $msg.subject;empty="[empty value]"$ (but keep the
> 'null=' part if we want to.
>
> Some basic ideas for what is actually empty:
> String empty = "";
> int empty = 0;
> Map/List(Collection) with .length()/.size() == 0
>
>
> - Jasper
>
> _______________________________________________
> 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