[stringtemplate-interest] Is $if()$ needed?
Terence Parr
parrt at cs.usfca.edu
Wed Aug 13 14:59:40 PDT 2008
On Aug 10, 2008, at 7:59 AM, Roman Odaisky wrote:
> Greetings,
>
> I wonder whether $if(attr)$ is redundant. Instead of
>
> $if(attr)$
> template
> $endif$
>
> one can write
>
> $attr:{template}$
>
> which looks cleaner.
But, you need
$if(attr)$, template$endif$
if you wanted to add a comma. Oh, could do $attr:{, template}$ I
guess. But, that only works for short templates. IF works great for
20 line inclusions.
> The only thing missing is the else part. Perhaps the grammar can be
> extended,
> for example, this way:
>
> $attr:{if}$
> $attr:{if}!{else}$
> $attr!{else}$
>
> This also allows to test for more than one attribute:
>
> $[a, b]:{template}$
>
> “If” constructs come from the imperative world. ST doesn’t have
> “for”, not
> even “foreach”, why should we have “if”?
An excellent question ;) It needs some kind of conditional and the
implied conditional of ':' would indeed work.
Ter
More information about the stringtemplate-interest
mailing list