You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Demetz Markus <e9...@student.tuwien.ac.at> on 2004/03/18 14:23:57 UTC
double parsing
hello,
i'm very new to velocity
i want to do a think like following:
my context looks like this:
context.put("name1", "something"),
context.put("name2", "somethingelse"), ...
my temlate has a loop:
#foreach($record in $list)
$name$velocityCount
#end
the result only is $name1 $name2 but I would like to have the context of
$name1 $name2 -> something and something else...
is this possible?
very thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: double parsing
Posted by Mike Kienenberger <mk...@alaska.net>.
Demetz Markus <e9...@student.tuwien.ac.at> wrote:
> hello,
>
> i'm very new to velocity
> i want to do a think like following:
>
> my context looks like this:
>
> context.put("name1", "something"),
> context.put("name2", "somethingelse"), ...
>
> my temlate has a loop:
> #foreach($record in $list)
> $name$velocityCount
> #end
>
> the result only is $name1 $name2 but I would like to have the context of
> $name1 $name2 -> something and something else...
> is this possible?
You can do this with the eval method of the RenderTool.
http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/generic/RenderTool.html
However, you might be better off changing the data struture(s) that you're
putting into your context rather than building variables in the template.
For example, put the names in a map with the $record as a key, or create a
new data struture that contains both record and names and put them in a
list, or just put the names in a list.
-Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org