You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Darren Evenson <DE...@safenetconsulting.com> on 2002/01/24 18:58:25 UTC

Escaping double quotes

I could not find this in the users guide.  I would like to know how to
escape a double-quote in a string literal with a value substitution.

For example, if the value of $onChange is "return false;", I would like the
following set statement

#set($onChangeText=" onchange=\"$onChange\"")

to set the value of $onChangeText to be:

 onchange="return false;"

I think my example would work if \" were how you escape a double quote, but
that doesn't seem to work.  Any suggestions?

Darren Evenson
SafeNet Consulting

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: VM_global_library.vm

Posted by "Charles N. Harvey III" <ch...@alloy.com>.
> > > Hello.
> > > I thought this would be trivial (and I am sure it is) but I don't seem
> > > to be able to figure it out.
> > >
> > > I am using a url resource loader like so for my templates:
> > > url.resource.loader.root = file:///c:/localhost/htdocs
> >
> > Is that the one from contrib?
>
> That is the one you wrote a while ago when I asked for URL loader and left
it in
> whiteboard/gier....
>
> > > /myapp/VM_global_library.vm.  I would like to put it in the "web"
> > > directory with all the other templates so that designers can make
> > > changes to the global macros.  I have been trying all kinds of
> > > configurations in the velocity.properties file to get it to read
> > > from the directory where my templates are but I can't seem to get it.
> >
> > Weird.  That should work like any other template.  The resource loader
is
> > set-up and ready before any VM system initialization.  I am surprised
you
> > can't drop it into htdocs/
>
> This is indeed wierd, even though I don't use macros (yet) my
> understanding is that all .vm files go through the same loading process...
>

I found it pretty strange too.  At first I was using #parse and #include
but I wanted to be able to send variables to my included files.  Like a
channel name or colors.  And the easiest way to do that is to instead use
a macro and not an #include.  Works fine if I define it on the page or
on the #included page... just not when I try to put my macro in the global
file.
I will keep moving the file around but so far it only gets read from /myapp.

Thanks for the help.

Charlie


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: VM_global_library.vm

Posted by Igor Fedulov <if...@outlook.net>.
> > Hello.
> > I thought this would be trivial (and I am sure it is) but I don't seem
> > to be able to figure it out.
> >
> > I am using a url resource loader like so for my templates:
> > url.resource.loader.root = file:///c:/localhost/htdocs
>
> Is that the one from contrib?

That is the one you wrote a while ago when I asked for URL loader and left it in
whiteboard/gier....

> > /myapp/VM_global_library.vm.  I would like to put it in the "web"
> > directory with all the other templates so that designers can make
> > changes to the global macros.  I have been trying all kinds of
> > configurations in the velocity.properties file to get it to read
> > from the directory where my templates are but I can't seem to get it.
>
> Weird.  That should work like any other template.  The resource loader is
> set-up and ready before any VM system initialization.  I am surprised you
> can't drop it into htdocs/

This is indeed wierd, even though I don't use macros (yet) my
understanding is that all .vm files go through the same loading process...

Best regards,
--
HTTP is a stateless protocol, and the Internet is a stateless development
environment
--
Igor Fedulov
E-mail : ifedulov@outlook.net
Work Ph: 773.775.1595
Home Ph: 773.281.8938
Cell Ph: 773.580.5935




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: VM_global_library.vm

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 1/24/02 6:18 PM, "Charles N. Harvey III" <ch...@alloy.com> wrote:

> Hello.
> I thought this would be trivial (and I am sure it is) but I don't seem
> to be able to figure it out.
> 
> I am using a url resource loader like so for my templates:
> url.resource.loader.root = file:///c:/localhost/htdocs

Is that the one from contrib?

> 
> So that I can keep my templates in a "web" directory, nowhere near the
> servlets.  Pretty basic stuff here.
> 
> What I am having trouble with is the global macros library.
> This is what the documentation has:
> velocimacro.library = VM_global_library.vm
> 
> And that is great.  But it means I have to put that file in
> /myapp/VM_global_library.vm.  I would like to put it in the "web"
> directory with all the other templates so that designers can make
> changes to the global macros.  I have been trying all kinds of
> configurations in the velocity.properties file to get it to read
> from the directory where my templates are but I can't seem to get it.

Weird.  That should work like any other template.  The resource loader is
set-up and ready before any VM system initialization.  I am surprised you
can't drop it into htdocs/

I assume you tried that?

I'll try it with the URLResourceLoader from contrib.

> 
> If anybody could give me a hand with this I would be greatful.
> 
> Thanks.
> 
> Charlie
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


VM_global_library.vm

Posted by "Charles N. Harvey III" <ch...@alloy.com>.
Hello.
I thought this would be trivial (and I am sure it is) but I don't seem
to be able to figure it out.

I am using a url resource loader like so for my templates:
	url.resource.loader.root = file:///c:/localhost/htdocs

So that I can keep my templates in a "web" directory, nowhere near the
servlets.  Pretty basic stuff here.

What I am having trouble with is the global macros library.
This is what the documentation has:
	velocimacro.library = VM_global_library.vm

And that is great.  But it means I have to put that file in
/myapp/VM_global_library.vm.  I would like to put it in the "web"
directory with all the other templates so that designers can make
changes to the global macros.  I have been trying all kinds of
configurations in the velocity.properties file to get it to read
from the directory where my templates are but I can't seem to get it.

If anybody could give me a hand with this I would be greatful.

Thanks.

Charlie

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Escaping double quotes

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 1/24/02 12:58 PM, "Darren Evenson" <DE...@safenetconsulting.com>
wrote:

> I could not find this in the users guide.  I would like to know how to
> escape a double-quote in a string literal with a value substitution.
> 
> For example, if the value of $onChange is "return false;", I would like the
> following set statement
> 
> #set($onChangeText=" onchange=\"$onChange\"")
> 
> to set the value of $onChangeText to be:
> 
> onchange="return false;"
> 
> I think my example would work if \" were how you escape a double quote, but
> that doesn't seem to work.  Any suggestions?
> 

Right now, there are no escaped values for the double-quoted string lits.  I
have (or had - need to grub around) code that did this, but never committed
as the discussion seemed to just fizzle re this subject.

What you can do for now is just

  #set($dq = '"')
  #set($onChangeText = " onchange=$dq$onChange$dq " )


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"We will be judged not by the monuments we build, but by the monuments we
destroy" - Ada Louise Huxtable


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>