You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Mike Kienenberger <mk...@alaska.net> on 2004/04/05 21:40:26 UTC

whitespace issue after #macro in multiline #if

Can anyone enlighten me as to why the newline is missing in this output?
Since the Amount: text is on its own line, shouldn't the output be 
terminated with a new-line?

I haven't noticed this problem in any of my other hundreds of convoluted 
velocity templates.

Velocity 1.3.1, velocity tools 1.1-beta1, jdk 1.4.2.

Thanks,

-Mike


Output:
======================================
Amount: $0.00Date: Day 7 of each month
======================================

Desired Output:
======================================
Amount: $0.00
Date: Day 7 of each month
======================================


Template:
======================================
#if ($isPayInFull)
Amount: Pay In Full#if(! $scheduledPayment.isRecurringValue()) 
(#formattedMoney($scheduledPayment.getAccount().getAmountDue())#end
#else
Amount: #formattedMoney($scheduledPayment.getAccount().getAmountDue())
#end
Date: ${scheduledPayment.dateToPayString()}
======================================


Macro:
======================================
#macro (formattedMoney $amountValue)${number.format('currency', 
$amountValue)}#end
======================================


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: whitespace issue after #macro in multiline #if

Posted by Mike Kienenberger <mk...@alaska.net>.
Geir Magnusson Jr <ge...@4quarters.com> wrote:
> That's cool.  We have to try to isolate that....

It appears to be caused by an in-line/one-line #if #end construction with 
only whitespace after the #end directive.  My tests show that both spaces 
and newlines are lost.

I've opened bug #28392 and attached an updated if.vm/if.cmp for detecting 
it.

In retrospect, I probably should have tested for the case of a single if 
statement, but the new if test cases are useful in any case.

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: whitespace issue after #macro in multiline #if

Posted by Mike Kienenberger <mk...@alaska.net>.
Thank a lot, Geir.

I was hoping it was user-error, but no, it's another obscure bug :)

I'll try to see if I can come up with a unit test that demonstrates it.  I 
wouldn't think it'd be too hard since what's below is half of the problem 
template.

-Mike


Geir Magnusson Jr <ge...@4quarters.com> wrote:
> That's cool.  We have to try to isolate that....
> 
> geir
> 
> On Apr 5, 2004, at 3:40 PM, Mike Kienenberger wrote:
> 
> > Can anyone enlighten me as to why the newline is missing in this 
> > output?
> > Since the Amount: text is on its own line, shouldn't the output be
> > terminated with a new-line?
> >
> > I haven't noticed this problem in any of my other hundreds of 
> > convoluted
> > velocity templates.
> >
> > Velocity 1.3.1, velocity tools 1.1-beta1, jdk 1.4.2.
> >
> > Thanks,
> >
> > -Mike
> >
> >
> > Output:
> > ======================================
> > Amount: $0.00Date: Day 7 of each month
> > ======================================
> >
> > Desired Output:
> > ======================================
> > Amount: $0.00
> > Date: Day 7 of each month
> > ======================================
> >
> >
> > Template:
> > ======================================
> > #if ($isPayInFull)
> >
> > Amount: Pay In Full#if(! $scheduledPayment.isRecurringValue())
> > (#formattedMoney($scheduledPayment.getAccount().getAmountDue())#end
> >
> > #else
> >
> > Amount: #formattedMoney($scheduledPayment.getAccount().getAmountDue())
> >
> > #end
> >
> > Date: ${scheduledPayment.dateToPayString()}
> >
> > ======================================
> >
> >
> > Macro:
> > ======================================
> > #macro (formattedMoney $amountValue)${number.format('currency',
> > $amountValue)}#end
> >
> > ======================================
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> >
> -- 
> Geir Magnusson Jr                                   203-247-1713(m)
> geir@4quarters.com
> 
> 
> ---------------------------------------------------------------------
> 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


Re: whitespace issue after #macro in multiline #if

Posted by Geir Magnusson Jr <ge...@4quarters.com>.
That's cool.  We have to try to isolate that....

geir

On Apr 5, 2004, at 3:40 PM, Mike Kienenberger wrote:

> Can anyone enlighten me as to why the newline is missing in this 
> output?
> Since the Amount: text is on its own line, shouldn't the output be
> terminated with a new-line?
>
> I haven't noticed this problem in any of my other hundreds of 
> convoluted
> velocity templates.
>
> Velocity 1.3.1, velocity tools 1.1-beta1, jdk 1.4.2.
>
> Thanks,
>
> -Mike
>
>
> Output:
> ======================================
> Amount: $0.00Date: Day 7 of each month
> ======================================
>
> Desired Output:
> ======================================
> Amount: $0.00
> Date: Day 7 of each month
> ======================================
>
>
> Template:
> ======================================
> #if ($isPayInFull)
>
> Amount: Pay In Full#if(! $scheduledPayment.isRecurringValue())
> (#formattedMoney($scheduledPayment.getAccount().getAmountDue())#end
>
> #else
>
> Amount: #formattedMoney($scheduledPayment.getAccount().getAmountDue())
>
> #end
>
> Date: ${scheduledPayment.dateToPayString()}
>
> ======================================
>
>
> Macro:
> ======================================
> #macro (formattedMoney $amountValue)${number.format('currency',
> $amountValue)}#end
>
> ======================================
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geir@4quarters.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org