[stringtemplate-interest] Expressions in $if(...)$ statements.

Magdalin, Vlad Vladimir_Magdalin at intuit.com
Thu May 14 15:07:07 PDT 2009


Hi,

 

I'm moving over from NVelocity to ST, and so far really liking the
strict separation of concerns. However, there are two areas of
functionality that are kind of in a gray area, and I'm wondering if ST
supports them:

 

1. Boolean operators in if() statements, for example:

 

$if(someBoolValue AND someOtherBoolValue)$ ... 

            ...

$endif$

 

Is this possible? I'm finding myself putting together extra Boolean
variables and passing them to the view data, but seems like this type of
simple logic does not violate M/V/C separation purity any more than a
one-value if statement does.  I've found this post
(http://www.antlr.org/pipermail/stringtemplate-interest/2005-June/000055
.html) from Terence, but can't seem to find if anything ever came of it.

 

2. Simple arithmetic operations that resolve to a boolean:

 

$if(items.Count == 1)$

 ... 

$endif$

 

Right now, I'm finding myself doing things like this to check if a list
has one and only one item:

 

This zoo contains $zebras.Count$ $if(rest(zebras))$ zebras $else$ zebra
$endif$

 

I'm wondering if even simple logic like this doesn't belong in the view
according to the ST methodology.  Any help or insight is appreciated!

 

Thanks,

Vlad

 

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20090514/3dd75d3b/attachment.html 


More information about the stringtemplate-interest mailing list