[My reply has bounced twice, being considered spam. This is my final
try, using text format rather than HTML.]
Quick solution: use poor man's escaping:
#set ($d = '$')
Then, you do something like this:
${d}!="W")H D=${d};18.${d}=E;H
That always works and is predictable, which cannot be said for
Velocity's quirky escaping rules.
Best regards.
On Wed, 2007-12-26 at 19:25 +1000, Arnold Somogyi wrote:
> Hi,
>
> I have been using Velocity Engine 1.5 to render html pages. It is very
> good and robostus engine. I have been building a lots of web pages
> width i18n (internationalization and localization) and Velocity engine
> help for me to switch in run time the labels on web page from
> database. It is working very good (I made a good and easy web
> developing framework).
>
>
> Now, I need to write some internationalized java script files. I want
> to use Velocity engine for simple assignment in my JavaScript code:
> var msgLoading = "$msgLoading";
> var msgDone = "$msgDone";
>
> I made a servlet which catch the all http/https *.js request and
> replace all velocity tokens with real value from database. It is
> working but I have a little and important problem:
> My favorite JavaScript prototype is jQuery. This prototype use very
> often the $ symbol. I try to use Velocity engine with jQuery but
> sometimes it is not working good because there are some character
> combination in jQuery source code which begin with $ character. Of
> course I do not assign value to these velocity tokens.
>
> For example:
>
> (1)
> in JavaScript source code: $Date
> on the screen: $Date
> result: OK
>
> (2)
> in JavaScript source code: $!="W")H D=$;18.$=E;H
> on the screen: $="W")H D=$;18.$=E;H
> result: ERROR
>
> (3)
> in JavaScript source code: (1m $!="W")H D=$;18.$=E;H
> u=/^[^<]*(<(.|\\s)+>)[^>]*$|^#(\\w+)$/;E.1b=E.3A={5N:G(c,a){c=c||U;9(1m
> c=="1M"){H m=u.2S(c
> on the screen: (1m $="W")H D=$;18.$=E;H
> u=/^[^<]*(<(.|\\s)+>)[^>]*$|^#(\\w+)$/;E.1b=E.3A={5N:G(c,a){c=c||U;9(1m
> c=="1M"){H m=u.2S(c
> result: ERROR
>
> (4)
> in JavaScript source code: $!
> on the screen: $
> result: ERROR
>
> (5)
> in JavaScript source code: $!!
> on the screen: $!
> result: ERROR
>
> (6)
> in JavaScript source code: $!!!
> on the screen: $!!
> result: ERROR
>
> (7)
> in JavaScript source code: ${!!}
> on the screen: ${!!}
> result: OK
>
> (8)
> in JavaScript source code: $#
> on the screen: $#
> result: OK
>
> You can see there are some wrong character combination: 2, 3, 4, 5 and
> 6. The velocity engine modified the original character combinations:
> $! -> $ and $!! -> $!.
> I think I have to configure the velocity engine that it do not modify
> $!... characters.
>
> Please help me to configure my velocity engine.
>
> Thx, SoMa
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Gonzalo Diethelm
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]