velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claude Brisson" <cla...@savoirweb.com>
Subject Re: The calling of EventCartridge's referenceInsert with the parameters of a velocimacro
Date Wed, 26 Mar 2003 16:15:38 GMT
> Now, my question is: would it break something if you
> didn't call referenceInsert when inserting a macro parameter?

Yes, the problem also exists with lines like #set("foo${bar}foo").

The reference insertion cartridge will stay useless for character formatting issues as long
as it will be impossible to distinguish
between direct and indirect insertion events.

Want an ugly hack ?

You can know if you are in a true insertion event if and only if all the lines of your stacktrace
that contain ".parser." also
contain ".render(" ....  ;-)

No, I'm kindof joking, but it could give some implementation ideas to people willing to write
the apropriate patch...

CloD

----- Original Message -----
From: "Panu Hällfors" <panu.hallfors@came.fi>
To: <velocity-user@jakarta.apache.org>
Cc: <panu.hallfors@came.fi>; "Timo Anttila" <timo.anttila@came.fi>
Sent: mercredi 26 mars 2003 10:12
Subject: The calling of EventCartridge's referenceInsert with the parameters of a velocimacro


> 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.
>
> Thanks,
>
>     Panu
>
> --
>      Panu Hällfors     | Chief Software Architect, Viloke Oy
>  panu.hallfors@came.fi |         http://www.came.fi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message