velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Kischuk <>
Subject Macro not evaluating
Date Wed, 14 Jul 2004 13:28:22 GMT
I'm having one of those bang-head-against-the-wall moments with Velocity
1.4.  I've got a formatter class with the following methods:


  public String currency(float amount) {

    Format formatter = NumberFormat.getCurrencyInstance();

    return formatter.format(new Float(amount));



  public String leftPad(String string, int width) {

    if (string.length() >= width) {

      return string.substring( string.length()-(width+1));


    StringBuffer output = new StringBuffer();

    for (int i=0; i < (width - string.length()); i++) {

        output.append(' ');




    return output.toString();



And have defined macros in my template:  


#macro(leftpad $message)

  ${formatter.leftpad($message, 8)}


#macro(currency $amount)${formatter.currency($amount)}#end


And called them in the template:


#foreach($orderLine in $orderLines)





Strangely, the #currency macro fully executes, but the #leftpad macro leaves
$formatter.leftpad($orderLine.quantity, 8) after the template has been
processed.  Is there something I'm doing wrong here?  And is there a
different way I should be doing this?




  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message