velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Eisan <b...@5star-network.com>
Subject Re: Two macros calling one another
Date Wed, 19 Jan 2005 11:06:43 GMT
Thanks Christoph. I have reconsidered the design and found a suitable 
way to avoid them calling each other. Thanks for the advice.

On Jan 18, 2005, at 3:47 pm, Christoph Reck wrote:

> Hi,
>
> 1rst: reconsider your design; your example causes a infinite depth
> call tree and will end up in an OutOfMemoryException... Velocity
> has some guards in recursive parses (property: 
> directive.parse.maxdepth = 10),
> but it does not look like it guards against deep macro calls.
>
> 2nd: You could resolve your question at runtime with the RenderTool,
> where the first macro indirectly calls the second one.
>
> Cheers,
> Christoph
>
> Brad Eisan wrote:
>> Hello,
>> I'm fairly new to Velocity and I've come across an interesting 
>> problem I haven't encountered before. I have read through the 
>> archives but cannot seem to find a solution to this. Though I may be 
>> missing something really obvious :)
>> This is a (silly) example of two macros which call one another (they 
>> exist together in a global macros file):
>> Macro 1:
>> #macro( title $product )
>>  You can get $product.name for #cost( $product ) now!
>> #end
>> Macro 2:
>> #macro( cost $product )
>>  <a href="/path/" title="#title( $product )">$product.amount USD</a>
>> #end
>> This outputs the error:
>> ERROR: VM #cost: error : too few arguments to macro. Wanted 1 got 0
>> My question is that if macros must be declared before they are used, 
>> how can you solve this since one macro will always have to be 
>> declared behind the other? If I reverse the order of the two in the 
>> file, the error is the same, but is for the other macro.
>> Thanks in advance,
>> Brad
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org


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