velocity-user mailing list archives

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

>>> "Stuart" == Stuart Churchill <> 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 Magnusson Jr.
System and Software Consulting
Developing for the web?  See
If you look up, there are no limits - Japanese Proverb

View raw message