velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Eisan <b...@5star-network.com>
Subject Two macros calling one another
Date Tue, 18 Jan 2005 15:34:25 GMT
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


Mime
View raw message