velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "???\(Brian Lee\)" <br...@3rsoft.com>
Subject RE: Range operator
Date Wed, 07 Mar 2001 12:32:36 GMT

I set value of $var in doBuildTemplate() method of Index.java source like this.

context.put("var", String.valueOf(10));

$var is substituted well outside the #foreach loop, 
but it's not in #foreach statement.


-----Original Message-----
From: gmj@mta6.srv.hcvlny.cv.net [mailto:gmj@mta6.srv.hcvlny.cv.net]On Behalf Of Geir Magnusson
Jr.
Sent: Wednesday, March 07, 2001 8:24 PM
To: velocity-user@jakarta.apache.org
Subject: Re: Range operator


À⵿̱ wrote:

> I have a question about range operator.
> This code is working
> 
>     #foreach ($i in [1..10])
>       $i
>     #end
> 
> But, that code is not working
> 
>     #foreach ($i in [1..$var])
>       $i
>     #end
> 
> and I set $var to 10.


The following example works :

#set($var = 10)

#foreach($i in [1..$var])
$i
#end

(I just tried it :)

Take a look at your template again to make sure that all is well - if
you still have a problem, send us your tempalate so we can take a look.

geir

-- 
Geir Magnusson Jr.                               geirm@optonline.com
Developing for the web?  See http://jakarta.apache.org/velocity/
Mime
View raw message