more inline... Sorry about HTML response...
-----Original Message-----
From: Jose Alberto Fernandez [SMTP:[EMAIL PROTECTED]]
Sent: Monday, December 04, 2000 3:50 PM
To: Velocity Dev (E-mail)
Subject: OK, what is the real syntax of VTL?
Hi,
�
I started really experimenting with Velocity this weekend and got a bunch of extrange
behavior, that I do not understand:
�
1) I could not use "-", "_", nor numbers in macro identifiers, got grammar errors.
��� Things started to work when I remove them. However the tests suit and the documentation,
����and the grammar seem to say otherwise.
�
No, in the macro identifiers you cannot use _ or -. You can use them in reference identifiers. I can't tell you right now why not :)
2) Given a macro, xyz,�with no arguments, the documentation says invocation is: #xyz()
however, that would put "()" as part of the output. I had to use #xyz without parentesis.
�
That's odd. I do it all the time. I have heard of this bug, and was trying to find it, but can't make it happen. If you can let us know the specifics - which OS, if it is the current CVS tree, whatever, that would help. I really want to find this :)
So, is this some but somewhere? a non commited change to the grammar? Or what.
A bug.
�
Some other things I noticed was that when evaluating macros, the entire body of the macro
gets reparsed everytime the macro is expanded. That seems like a very costly operation
when one has lots of macros (in my case I have lots and they are heavily called) I am
doig XML-XML translations with this.
Yes, that is what happens right now. I have plans for optimizing it to avoid the reparse.
�
I can see that such an approach is needed for interpolation (having snippets of code
expanded in place on the macro) but for that small use it seems that the price is
too big. An #eval($code) directive that specializes on this kind of thing seems to me
to be more approrpiate. This can really speed things up, at least in my case.
You can use string interpolation to have any bit of VTL parsed and rendered. Just do :
"$foo" or "#if(true) $foo #end"
See test/templates/interpolation.vm
�
Am I misunderstanding how this stuff works?
Nope. You found some bugs, and a place where we are going to optimize. Please, if you can supply more info re the #xyz() bug, that would be great.
geir
�
Jose Alberto
�
� << File: Jose Alberto Fernandez.vcf >>
