As I mentioned in my  reply sometime ago, I already got it fixed. Here it is -

document.ManageSiteLinksForm.preVTL.value="\#if(\$SITE.getSiteDocs().size() > 0)";

Both, # and $ needed to be escaped here!

- Manish



----- Original Message ----- From: "Claude Brisson" <[EMAIL PROTECTED]>
To: "Velocity Users List" <[email protected]>
Sent: Thursday, February 08, 2007 4:49 PM
Subject: Re: Escaping VTL in a string


ooops - then I try again...

#set($value = '#if($SITE.getSiteDocs().size()>0)')
document.ManageSiteLinksForm.preVTL.value="$value";

Am I right this time?

 Claude

Le jeudi 08 février 2007 à 20:11 +0900, trad-ex a écrit :
Hi Claude,

You maybe make a little mistake, I guess.
document.ManageSiteLinksForm.preVTL.value means Javascript context.
And the left-hand side of #set shoud start with "$", shouldn't it ?
But the statement below will not be what Manish wants.

document.ManageSiteLinksForm.preVTL.value='#if($SITE.getSiteDocs().size
()>0)'

It will fail because of ParserErrorException ;-)

Best Regards,
trad-ex


>You could also use single quotes, that is:
>
>#set(document.ManageSiteLinksForm.preVTL.value='#if($SITE.getSiteDocs().
>size()>0)')
>
>
>  Claude
>
>Le jeudi 08 février 2007 à 18:49 +0900, trad-ex a écrit :
>> Hi Manish,
>>
>> My solution is like below.
>>
>> #set( $sharp = '#' )
>> document.ManageSiteLinksForm.preVTL.value
>>    ="${sharp}if(\$SITE.getSiteDocs().size() > 0)";
>>
>> Please try it.
>>
>> Best Regards,
>> trad-ex
>>
>> >For some HTML form, I need to set value of variable as VTL string, but I
>> >want
>> >that value to be taken as "raw" VTL string and not as evaluated VTL
>> >string.
>> > This
>> >is what I am doing in the JavaScript of my .vm file --
>> >
>> >document.ManageSiteLinksForm.preVTL.value="\#if($SITE.getSiteDocs().size
>> >() >
>> >0)";
>> >
>> >but this evaluates to #if(0 > 0) and not \#if($SITE.getSiteDocs().size()
>> > >
>> >0)
>> >that I want
>> >
>> >How can I achieve this?? How can escape executing of this VTL inside the
>> >string??? "\" doesn't seem to do that
>> >
>> >TIA,
>> >- Manish
>> >
>> >
>> >
>> >
>> >---------------------------------------------------------------------
>> >To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >For additional commands, e-mail: [EMAIL PROTECTED]
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to