velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Eisan <>
Subject Two macros calling one another
Date Tue, 18 Jan 2005 15:34:25 GMT

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 $ for #cost( $product ) now!

Macro 2:
#macro( cost $product )
  <a href="/path/" title="#title( $product )">$product.amount USD</a>

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,

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message