[stringtemplate-interest] Conditional statements
Galen Dunkleberger
galendunkleberger at gmail.com
Fri May 5 18:46:01 PDT 2006
Well yes and no...let say for example i have two conditions that need to
be met to display something. If either condition fails i want to display
something else (the same something else). With nested ifs i have to
have that "same something else" twice. So...
$if(a.x)$
$if(b.y)$
display blah 1
$else$
display blah 2
$endif$
$else$
display blah 2
$endif$
as opposed to
$if(a.x && b.y)
display blah 1
$else$
display blah 2
$endif$
This can start to make a template rather complex if there are 'N'
multiple conditions that need to be met in order to "display blah 1".
Now I realize complicated conditional code should be wrapped in the
object in some simple shouldIDisplayBlah1() method. However I'm getting
into situations where there are conditions that need to be met between
multiple objects (which don't know anything about each other)....so i
could A) create a third wrapper object to process the conditional state
of the various object or B) work with nested ifs. 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.
My two cents,
Galen
On Fri, 2006-05-05 at 15:05 -0700, Terence Parr wrote:
> On May 5, 2006, at 6:01 AM, Galen Dunkleberger wrote:
>
> > Is it possible to somehow have multiple arguments for a conditional
> > statement other than using nested ifs. For instance something like...
> >
> > $if(a.x && b.z)$
> > show something
> > $else$
> > show something else
> > $endif$
> >
> > If this is not currently possible could I make a feature request?
>
> I've thought about it as it's the same as a nested IF statement right?
>
> Ter
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list