velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: Escaping VTL elements
Date Sat, 15 Sep 2001 18:19:13 GMT
On 9/14/01 8:48 PM, "Peter Mutsaers" <peter@mutsaers.com> wrote:

>>> "Stuart" == Stuart Churchill <SChurchill@caluk.com> writes:
> 
>   Stuart> Secondly, an escaping problem that I've not yet found a
>   Stuart> workaround for. My destination template should contain a
>   Stuart> reference '$!BreederSurname'. My source template includes
>   Stuart> a reference '$column.getName()', which in this instance
>   Stuart> returns the value "BreederSurname". How do I combine the
>   Stuart> two ?
> 
> The lack of normal \-style escaping has been a great source of
> annoyance for me too.

There is \-style escaping for references and directives.

See the Users' Guide.

I assume you mean in strings.  We don't have \-style escaping of \n, ", ' in
VTL strings, but we can drop that into 1.3.

> 
> I've used some addition to the context, such as $q being predefined as ".
> 
> But that is an ugly hack of course, and looks horrible on template
> pages with lots of macro's etc (where all parameters containing
> characters like " have to be escaped, and you can't use '...' because
> the parameter may contain context variables too.
> 
> I've been considering to add a normal escaping mechanism myself, I can
> hardly imagine that this doesn't cause big grieve for "everyone".

It seems not to.

For example

  #set($foo = ' This is my "string" ')

Is perfectly legal VTL, and will be output as

  This is my "string"

 
> Instead I must say I have stopped using velocity (moved back to JSP,
> but now strictly as a template mechanism under control of a
> servlet-controller).

That's too bad.

geir

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
If you look up, there are no limits - Japanese Proverb


Mime
View raw message