+1 to dropping the old #set syntax.
I hope in this debut with Mr. Parser you will have the chance to fix
some problems like it refuting double-quoted strings as parameters
ending in a $ or #. Also it might be the chance to get the whitespace
handling fixed. This should demonstrate the issue:
---
#if( !$foo )
#set( $bar = "bar" )
\$bar is now set to $bar
#if( $bar )
#set( $foo = $bar )
#else
#set( $foo = "bar" )
#end
\$foo is now set to $foo
List: #foreach( $item in $list )
$item#if( $velocityCount != $list.size() ),#end
#end
That was it!
#end
---
produces (within example.vm):
---
$bar is now set to bar
$foo is now set to bar
List: ArrayList element 1, ArrayList element 2, ArrayList element 3,
ArrayList element 4 That was it!
---
instead of
---
$foo is now set to bar
List:
ArrayList element 1,
ArrayList element 2,
ArrayList element 3,
ArrayList element 4
That was it!
---
Here the whitespace is not what would be expected:
1. #ends chewed up the EOL (no empty line to the next)
2. The set is nice and transparent (it even slurped the
leading whitespaces). But leading whitespaces of an
indented #if, #foreach, #macro, etc. still show up
in the output.
3. If this snippet resides in a parsed file, I get:
---
bar is now set to bar
---
where the escaping was ignored.
(look at the output of the admin app and pjyve and you
will see the strange formatting resulting from indented
directives).
The right solution would be to absorb leading/trailing
whitespaces *only* when the directive is standalone in
a line. If the designer wishes, he can then supress
any leading whitespaces by replacing it with a #* ... *#,
and trailing EOL by appending a ##.
:) Chistoph
"Geir Magnusson Jr." wrote:
>
> It's time to say goodbye to an old friend, the original #set directive.
> In it's brief time with us, in it's binary home, Ol' #set lived each
> assignment with zest and passion. And those that knew Ol' #set will
> always remember how it always teased Mr. Parser with it's
> non-conformity, refusing to simply 'go along' with the syntax of the
> other directives, refusing to be able to be used inline. It was this
> appreciation for the small things (like "is a + is bound to the
> directive or the following schmoo?") But fear not, the spirit of Ole'
> #set will always be with is, in #set()...
>
> Ok. I was at a funeral yesterday, hence the eulogy format :)
>
> Seriously, lets finally knock the old #set off. I propose (and will do
> it if no one yipes) that it goes away Real Soon Now. If there is no
> opposition, I will remove it.
>
> To recap :
>
> A LONG time ago, we changed the #set directive to conform with the rest
> of the directives, in that the expression is contained in parenthesis -
>
> Old : #set $foo = 'bar'
>
> 'New' : #set( $foo = 'bar' ) or #set ( $foo = 'bar') or ....
>
> We currently still support the old way (w/o the parens), and log as a
> convenience to the user, but lets get rid of it. It's been a long time,
> it was well publicised, and the log, if you read it, tells you in which
> template at what line you have the old syntax.
>
> All in favor, say '+1'. Actually, it's more important to understand who
> / why against, so all not in favor, -1 and why...
>
> geir