[stringtemplate-interest] Conditional statements

Terence Parr parrt at cs.usfca.edu
Sat May 6 15:12:05 PDT 2006


On May 6, 2006, at 12:51 PM, David Moshal wrote:

> I have to admit that I wouldn't mind expression and logic  
> evaluation capabilities in the view (template),
> seems to me that this ought to be possible without risking the view:
> - changing the model, or
> - becoming a controller.

Well, technically no computation can be done so no && and not even  
nested IF should be allowed.  Technically that computation should be  
done in model and sent into template, but...that's inconvenient.  As  
long as they are boolean results, nested IF is ok.  As for &&, I'm  
thinking that might be *too* convenient... ;)

> My problem with the current system is that if one is passing in a  
> collection of objects,
> the lack of logic or expression evaluation in the view requires one  
> to either:
> 1. create custom view objects from the model (which reduces  
> performance), or

Are you familiar with the "name.{prop1, prop2}" notation inside  
setAttribute?  Creates custom aggregates.

> I've always thought that extreme MVC separation isn't the goal, but  
> rather that each element of the
> M,V and C, should contain elements of all three, with particular  
> emphasis on one.

My experience building large web and code gen systems is that the  
strict enforcement is a guarantee that you can re-skin your web site  
or retarget your codegenerator.  Otherwise, you cannot do so  
effectively.

Ter


More information about the stringtemplate-interest mailing list