[stringtemplate-interest] dealing with empty list values
Joshua Royalty
joshua.royalty at gmail.com
Sat Feb 6 02:52:50 PST 2010
Hi, I ran into a bit of a stumbling block with a list containing null
values. It seems that ST automatically skips over null values when
iterating over a list.
I searched the archives and found this thread
http://markmail.org/search/?q=list%3Astringtemplate+dealing+with+empty+list+values#query:list%3Astringtemplate%20dealing%20with%20empty%20list%20values+page:1+mid:fvkxdehqyuyu4jxp+state:results
Was a solution ever implemented?
Personally I would find it most intuitive to have the default be to not skip
nulls. Such that "$values:{ v | $if(v)$$v$$else$-1$endif$" would be
identical to "$values; separator=\", \", null=\"-1\"$"
Instead, if you sent values to {test1, null, test2} you get
test1, test2
test1, -1, test2
"$values:{ v | $if(v)$$v$$else$-1$endif$}; separator=\", \", null=\"-1\"$"
also prints 'test1, -1, test2'
Its not logically consistent to skip nulls when iterating over a list and
treat them as "" (Empty String) everywhere else. (A case could also be made
that it is not logically consistent to treat them as false in the if
statement as well)
If someone wants to clean nulls out of the list they can use the strip()
function, though strictly speaking that should have been handled by the
model.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20100206/66eec9fb/attachment.html
More information about the stringtemplate-interest
mailing list