velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <mkien...@alaska.net>
Subject Re: constructing variable names dynamically
Date Wed, 25 Aug 2004 15:09:13 GMT
"Ravikanth.L" <ravikanth_lolur@yahoo.com> wrote:
> it in the context. But still i am not getting the
> exact syntax to use dynamic variables.
> 
>  i tried with the following code
> 
>  \\ in my java code 
>   context.put("element","name");
>   context.put("elementValue","Ravi");
> 
>  i want to create a variable with name $name and its
> value should be "Ravi"
> 
> \\in my template i tried like this:
>  
>  render.recurse("#set($$element = $elementValue)")
>  Hello $name // as my template already using $name to
> display name.

You probably also need to do something like this:

	context.put("dollarSymbol","$");

I'm not sure what the exact syntax for the renderer is as I've never used 
it, but maybe...	render.recurse("#set(${dollarSymbol}${element} = 
${elementValue})")

or

	render.recurse("#set(${dollarSymbol}${dollarSymbol}element = 
${dollarSymbol}elementValue)")

However, why not just set all of these values from your java code?

-Mike

---------------------------------------------------------------------
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