velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <mkien...@alaska.net>
Subject Re: Writing JavaScript with Velocity
Date Tue, 28 Oct 2003 21:40:58 GMT
Matt Raible <MRaible@RESORTQUEST.com> wrote:
> I have the following VTL that I'm using to write JavaScript:
> 
>   #if ($level == 0)
>     #set ($node = $menu.name)
>     var $node = new WebFXTree('$menu.title');
>     $node.setBehavior('classic');
>   #end
> 
> It's puking at $node.setBehavior.  Ideally, this would print out something
> like the following:
> 
>     var tree = new WebFXTree('Root');  
>     tree.setBehavior('classic');
> 
> Is this possible, or do I have to use JavaScript's eval function?

WARNING: I'm no expert but......

I think you need to put the single quotes into a context variable.

Something like

#set ($singlequote = "'")  ## not sure if this is how you get one in there

[...]

var $node = new WebFXTree(${singlequote}${menu}.title${singlequote});
$node.setBehavior(${singlequote}classic${singlequote});

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message