[stringtemplate-interest] suggestion for a new option 'empty='

Jasper Roel jasper_roel at yahoo.com
Wed Nov 26 11:57:00 PST 2008


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


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20081126/2af24794/attachment.html 


More information about the stringtemplate-interest mailing list