velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Panu Hällfors <>
Subject The calling of EventCartridge's referenceInsert with the parameters of a velocimacro
Date Wed, 26 Mar 2003 09:12:47 GMT
I'm experiencing slight inconvenience with EventCartridge's
referenceInsert being called multiple times when calling
a velocimacro in some situations.

An example:
1. #macro (displayThis $text)
2.     $text
3. #end
4. #set( $name = "Panu & others" )
4. #displayThis("Hello, $name")

Now, my EventCartridge implementation filters all special
characters to HTML entities (such as & to &amp;)
However, here it's called twice for the contents of $name:
first on line 4 when $name is inserted and then again inside
the macro on line 2 when the new string
(with "Hello, " appended to $name), is inserted.

So, the output of the above is "Hello, Panu &amp;amp; others",
not quite what you'd expect, eh?

I'm able to work around this by using a pull tool which
returns data from context without filtering but it's a bit
error-prone since you always have to remember to use the
tool if you construct a new string in macro parameter.

Now, my question is: would it break something if you
didn't call referenceInsert when inserting a macro parameter?
Another solution would be to let referenceInsert know
if the reference being processed is a macro parameter
so that it could skip filtering for parameters.

It seems that velocity already skips the calling of
referenceInsert for macro parameters that have been
processed already but the problem arises when you
implicitely create a new variable in a method call.



     Panu Hällfors     | Chief Software Architect, Viloke Oy |

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message