[stringtemplate-interest] Conditional statements

David Moshal dmoshal at gmail.com
Sat May 6 12:51:32 PDT 2006


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.

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
2. alter the model, so that these objects fit the view (which breaks MVC
separation)

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.

Indeed, this is currently the case with ST, which supports $if$ anyway (a
'C').
And the template itself is persistent, so it is a Model for the View.

My ZAR 0.02.

Dave



On 5/6/06, Kay Roepke <kroepke at dolphin-services.de> wrote:
>
>
> On 6. May 2006, at 3:46 Uhr, Galen Dunkleberger wrote:
>
> > However it's my
> > opinion that by allowing multiple conditions for an if statement you
> > simplify the template...and what I like about string template is it's
> > simplicity.
>
> While I can understand your request and do support it (sorta ;)), I
> think
> it should be well considered to add expressions, even if they are "just"
> boolean. It might awake those sleeping wishes for full fledged
> arithmetics
> and such beasts (aka The Bad Thing(tm)).
>
> As a workaround you can always provide template variables which have the
> value of those boolean expressions if that would make your life that
> much easier.
> After all the controller is allowed to know about the logic of the
> view. It still
> wouldn't compromise the MVC pattern of ST, as long as there isn't any
> actual text in
> the controller.
>
> This is the way I handle things at work (where we have a template
> system quite similar to
> ST) and that works pretty well. Having boolean expressions naturally
> simplifies things when
> the requirements change, but it would require some work in the
> grammar (which may or may not
> be easy/quick to do, I don't know for sure).
>
> My €0.02
>
> -k_______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20060506/7ad5e941/attachment.html


More information about the stringtemplate-interest mailing list