You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Geir Magnusson Jr." <ge...@optonline.net> on 2002/03/18 14:27:21 UTC

Re: Macro libraries, using existing helpers

On 3/18/02 7:11 AM, "Ben Peter" <bp...@zentropypartners.com> wrote:

> Hi all,
> 
> 
> I am trying to have a simple way to escapeXml() a text in a velocity template
> (Simply to display text returned by a bean on a page).
> 
> I have put an instance of org.apache.taglibs.string.util.XmlW into the context
> under the key `xml' and then tried
> 
> $xml.escapeXml( $element.getText() ), but this doesn't seen to do the job, I
> always get the expression itself in the output.

I assume it's a public function that takes a String arg?

> 
> So, my first question is, what am I doing wrong here, am I totally blind?

Ensure that it's a public method on a public class.  Velocity respects such
things...
 
> Then again, as this is such a common need, am I missing a point and is there
> and kind of standard library of velocity macros around which will do the job?


Another approach is to use ReferenceInsertion events and do it then - keeps
the template clean...

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>