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

DVD dvd at newfoundmarket.com
Fri May 15 06:26:23 PDT 2009


Pardon me if I am being repetitious for the simple expression evaluation 
option I brought up
a few days ago. This "AND" needs is one of those simple expressions that 
could be
resolved with a general purpose expression evaluation approach in stead of
ad hoc resolution. I feel this can be achieved and with recommendation 
that author
should refrain from using it unless model can not be modified to provide 
the property

Terence Parr wrote:
> On May 14, 2009, at 3:07 PM, Magdalin, Vlad wrote:
>
>   
>> 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?
>>     
>
> not currently...I have to do nested IF now, which is effectively an  
> AND...in new version of ST I think it will be alllowed.
>
>   
>> 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.
>>     
>
> not yet ;)
>
>   
>> 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:
>>     
>
> You can do $if(rest(names))$ which asks if it has more than a first  
> 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!
>>
>>     
>
> It's a slippery slope. can't really allow logic in expressions  
> involving values.
>
> Ter
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>   



More information about the stringtemplate-interest mailing list