You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Shinobu Kawai <sh...@gmail.com> on 2005/02/24 09:38:35 UTC
Escaping in VTL (was Re: Velocity JSP Generation)
Hi Will,
> > #*
> > First time I've ever heard of "creating JSP with Velocity". :)
> > I wonder if anybody uses Velocity to create Velocity templates. I
> > might need to add vtl to the EscapeTool. (half joking, half...)
> > *#
>
> Ha. I wrote an app that uses Velocity to generate Velocity templates. It's
> a "quick start" tool to generate a Velocity-based application for new users.
Wow! Great work. :-)
> Escaping the VTL properly was a little challenging, but otherwise it was no
> big deal.
I still don't "get" the whole escaping scheme, partly because I can't
find any documentation that is completely correct. We might want a
document totally devoted to escaping in VTL. :(
Best regards,
-- Shinobu
--
Shinobu Kawai <sh...@gmail.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Escaping in VTL (was Re: Velocity JSP Generation)
Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Mike,
> > I still don't "get" the whole escaping scheme, partly because I can't
> > find any documentation that is completely correct. We might want a
> > document totally devoted to escaping in VTL. :(
>
> Escape all [$], [#], ["], [!] and [']. (actually, ! might be overkill, but
> better safe than sorry.) Just use your tool :)
I'll add [\] to that. :)
> Always use formal notation ${x}
>
> That's always worked for me, and never surprises me.
If I can be sure that EscapeTool will be in the Context, it isn't hard
at all. But what if it's not?
Anyways, what I wanted to say was "I want a complete and accurate
document on how escaping works in Velocity." It should cover
references, directives, silent notation, formal notation, schmoo...
Anything else?
Best regards,
-- Shinobu
--
Shinobu Kawai <sh...@gmail.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Escaping in VTL (was Re: Velocity JSP Generation)
Posted by Mike Kienenberger <mk...@alaska.net>.
Will Glass-Husain <wg...@forio.com> wrote:
> Doesn't quite work that easily.
>
> The problem is that if "#directive" is not an actual macro, than
\#directive
> is shown verbatim. You only should escape when the same code is legit in
> both the source and the generated Velocity. This can be a little
confusing.
Now, see, that's exactly the kind of garbage I avoid. I see now I left off
another "rule" that I follow.
- Always perform escaping with variable replace (preferrably EscapeTool).
Ie, ${esc.hash} or ${poundSign} and not \#
-Mike
> ----- Original Message -----
> From: "Mike Kienenberger" <mk...@alaska.net>
> To: "Shinobu Kawai" <sh...@gmail.com>; "Velocity Users List"
> <ve...@jakarta.apache.org>
> Cc: "Velocity Users List" <ve...@jakarta.apache.org>
> Sent: Thursday, February 24, 2005 7:07 PM
> Subject: Re: Escaping in VTL (was Re: Velocity JSP Generation)
>
>
> > Shinobu Kawai <sh...@gmail.com> wrote:
> >> > Escaping the VTL properly was a little challenging, but otherwise it
> >> > was
> > no
> >> > big deal.
> >>
> >> I still don't "get" the whole escaping scheme, partly because I can't
> >> find any documentation that is completely correct. We might want a
> >> document totally devoted to escaping in VTL. :(
> >
> > Escape all [$], [#], ["], [!] and [']. (actually, ! might be overkill,
> > but
> > better safe than sorry.) Just use your tool :)
> >
> > Always use formal notation ${x}
> >
> > That's always worked for me, and never surprises me.
> >
> > -Mike
> >
> > ---------------------------------------------------------------------
> > 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Escaping in VTL (was Re: Velocity JSP Generation)
Posted by Nathan Bubna <nb...@gmail.com>.
agreed. this is not my preferred escaping system either, but we can't
just go changing it now. i can't think of any way to make such a
change backwards compatible.
the best that could be done (if someone is interested in doing it) in
1.x, would be to make escaping behavior configurable via a simple
property toggle, but even then, the current behavior would have to
stay the default option.
On Fri, 25 Feb 2005 11:17:36 -0800, Will Glass-Husain <wg...@forio.com> wrote:
> Yes. It's confusing. But I'd vote against changing this (for the 1.x
> series) or all
> my app-generating templates will break.
>
> WILL
>
> ----- Original Message -----
> From: "Gonzalo Diethelm" <go...@aditiva.com>
> To: "'Velocity Users List'" <ve...@jakarta.apache.org>
> Sent: Friday, February 25, 2005 7:09 AM
> Subject: RE: Escaping in VTL (was Re: Velocity JSP Generation)
>
> >> Doesn't quite work that easily.
> >>
> >> The problem is that if "#directive" is not an actual macro,
> >> than \#directive
> >> is shown verbatim. You only should escape when the same
> >> code is legit in
> >> both the source and the generated Velocity. This can be a
> >> little confusing.
> >
> > I know there is no agreement on this. To me, this behavior breaks the
> > principle of least astonishment.
> >
> > http://en.wikipedia.org/wiki/Principle_of_least_astonishment
> >
> > Regards,
> >
> >
> > --
> > Gonzalo Diethelm
> > gonzalo.diethelm@aditiva.com
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Escaping in VTL (was Re: Velocity JSP Generation)
Posted by Will Glass-Husain <wg...@forio.com>.
Yes. It's confusing. But I'd vote against changing this (for the 1.x
series) or all
my app-generating templates will break.
WILL
----- Original Message -----
From: "Gonzalo Diethelm" <go...@aditiva.com>
To: "'Velocity Users List'" <ve...@jakarta.apache.org>
Sent: Friday, February 25, 2005 7:09 AM
Subject: RE: Escaping in VTL (was Re: Velocity JSP Generation)
>> Doesn't quite work that easily.
>>
>> The problem is that if "#directive" is not an actual macro,
>> than \#directive
>> is shown verbatim. You only should escape when the same
>> code is legit in
>> both the source and the generated Velocity. This can be a
>> little confusing.
>
> I know there is no agreement on this. To me, this behavior breaks the
> principle of least astonishment.
>
> http://en.wikipedia.org/wiki/Principle_of_least_astonishment
>
> Regards,
>
>
> --
> Gonzalo Diethelm
> gonzalo.diethelm@aditiva.com
>
>
> ---------------------------------------------------------------------
> 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
RE: Escaping in VTL (was Re: Velocity JSP Generation)
Posted by Gonzalo Diethelm <go...@aditiva.com>.
> Doesn't quite work that easily.
>
> The problem is that if "#directive" is not an actual macro,
> than \#directive
> is shown verbatim. You only should escape when the same
> code is legit in
> both the source and the generated Velocity. This can be a
> little confusing.
I know there is no agreement on this. To me, this behavior breaks the
principle of least astonishment.
http://en.wikipedia.org/wiki/Principle_of_least_astonishment
Regards,
--
Gonzalo Diethelm
gonzalo.diethelm@aditiva.com
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Escaping in VTL (was Re: Velocity JSP Generation)
Posted by Will Glass-Husain <wg...@forio.com>.
Doesn't quite work that easily.
The problem is that if "#directive" is not an actual macro, than \#directive
is shown verbatim. You only should escape when the same code is legit in
both the source and the generated Velocity. This can be a little confusing.
Will
----- Original Message -----
From: "Mike Kienenberger" <mk...@alaska.net>
To: "Shinobu Kawai" <sh...@gmail.com>; "Velocity Users List"
<ve...@jakarta.apache.org>
Cc: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Thursday, February 24, 2005 7:07 PM
Subject: Re: Escaping in VTL (was Re: Velocity JSP Generation)
> Shinobu Kawai <sh...@gmail.com> wrote:
>> > Escaping the VTL properly was a little challenging, but otherwise it
>> > was
> no
>> > big deal.
>>
>> I still don't "get" the whole escaping scheme, partly because I can't
>> find any documentation that is completely correct. We might want a
>> document totally devoted to escaping in VTL. :(
>
> Escape all [$], [#], ["], [!] and [']. (actually, ! might be overkill,
> but
> better safe than sorry.) Just use your tool :)
>
> Always use formal notation ${x}
>
> That's always worked for me, and never surprises me.
>
> -Mike
>
> ---------------------------------------------------------------------
> 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
Re: Escaping in VTL (was Re: Velocity JSP Generation)
Posted by Mike Kienenberger <mk...@alaska.net>.
Shinobu Kawai <sh...@gmail.com> wrote:
> > Escaping the VTL properly was a little challenging, but otherwise it was
no
> > big deal.
>
> I still don't "get" the whole escaping scheme, partly because I can't
> find any documentation that is completely correct. We might want a
> document totally devoted to escaping in VTL. :(
Escape all [$], [#], ["], [!] and [']. (actually, ! might be overkill, but
better safe than sorry.) Just use your tool :)
Always use formal notation ${x}
That's always worked for me, and never surprises me.
-Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org