I would have assumed the quoted string would be evaluated before being
passed in to the macro.  Hence $i is invalid reference when it is evaluated,
and we'd always see "no no no".

WILL

On Sun, Oct 12, 2008 at 5:17 PM, Byron Foster <[EMAIL PROTECTED]> wrote:

> I went back and pulled the velocity source to the revision (471881) before
> the changes to bug 285 and found that the behavior is as expected, so I
> conclude this is a bug :) which has been created here:
>
> https://issues.apache.org/jira/browse/VELOCITY-630
>
>
> On Oct 10, 2008, at 17:04 , Byron Foster wrote:
>
>  Given the following:
>>
>> #macro(test $a $b)
>>  #foreach($i in $a) $b #end
>> #end
>> #test( [1, 2, 3] "#if($i == 2) yes #else no #end")
>>
>> I would expect the output:
>>
>> no  yes  no
>>
>> Instead, I get
>>
>> no  no  no
>>
>> However, if I have
>>
>> #macro(test $a $b)
>>  #set($i = 1) $b #set($i = 2) $b #set($i = 3) $b
>> #end
>> #test( [1, 2, 3] "#if($i == 2) yes #else no #end")
>>
>> then I get:
>> no  yes  no
>> as expected.
>>
>> I would say there is a bug here.  The Foreach directive explicitly sets $i
>> in the localscope.  If I replace the explicit put to the localscope with a
>> regular put, the first macro case works.  I was looking at the following
>> issues where the modification to Foreach was mode.
>>
>> https://issues.apache.org/jira/browse/VELOCITY-285
>>
>> Now, my test change to Foreach breaks issue 285, but I'm not convinced
>> that the resolution to 285 is complete.  Thoughts?
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Forio Business Simulations

Will Glass-Husain
[EMAIL PROTECTED]
www.forio.com

Reply via email to