[stringtemplate-interest] whitespace in IF

Terence Parr parrt at cs.usfca.edu
Sat Nov 7 12:42:33 PST 2009


On Nov 7, 2009, at 11:56 AM, Sam Harwell wrote:

> I approve of this. Consistent and easy to explain. :)
>
> I do need && in this case:
>
> return
> <if(COND1)>
> <if(COND2)>
> <if(COND3)>
> <retval>
> <endif>
> <endif>
> <endif>
> ;
>
> To make it:
>
> return<if(COND1&&COND2&&COND3)> <retval><endif>;

just added that (and ||) :)

> In fact, you could preserve *all* whitespace as long as you give the
> option during rendering to "strip trailing whitespace from lines". If
> things are getting unreadable, the following is an option for template
> writers:
>
> return<if
> 	(COND1
> 	 && COND2
> 	 && COND3)> <retval><endif>;

whitespace is ignored *inside* expressions so that works now :)

What about your

foo(users) ::= <<
<table border=1>
$users:row()$
</table>
 >>

Seems we want to ignore one \n char at start or wehave to do:

foo(users) ::= <<<table border=1>
$users:row()$
</table>
 >>

which is ugly.

Maybe then with some templates we can make a consistent by ignoring  
one space or newline:

{x |
blort
}

same as {x | blort} same as {x |blort}

Ter


More information about the stringtemplate-interest mailing list