You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Leyzerzon, Simeon G" <Si...@gs.com> on 2003/02/26 21:25:52 UTC

white space handling rules

Hello Velocitizens,


Are there the definitive rules on how the white space in code affects
placement of
the white space in the output.

Here is my sutiatuion:

This template:
=========================================================================
#set($imperial = ["Munetaka", "Koreyasu", "Hisakira", "Morikune"])
#set($counter = 0)
#foreach($shogun in $imperial)
#set($counter = $counter +1)
	#set($numberOfColumns = $imperial.size())#if($counter <
$numberOfColumns)$shogun~#else$shogun#end#end
##counter is: $counter

imperial size is: $imperial.size()
============================================================================

produces the output:
========================================================================
Munetaka~Koreyasu~Hisakira~Morikune
imperial size is: 4

=======================================================================

whereas this code in template: (the only difference is in placement of
#if directive
========================================================================

#set($imperial = ["Munetaka", "Koreyasu", "Hisakira", "Morikune"])
#set($counter = 0)
#foreach($shogun in $imperial)
#set($counter = $counter +1)
	#set($numberOfColumns = $imperial.size())
	#if($counter < $numberOfColumns)$shogun~#else$shogun#end#end
##counter is: $counter

imperial size is: $imperial.size()

=========================================================================

produces the following output:
=========================================================================
	Munetaka~	Koreyasu~	Hisakira~	Morikune
imperial size is: 4

=========================================================================

The behaviour in the first output is exactly what I need.
I just want to understand how the placement of the commands in the template
affects the output (in terms of the whitespace).

Thank you in advance,
Simeon

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


Re: white space handling rules

Posted by Dave Newton <da...@solaraccess.com>.
On Wed, 2003-02-26 at 15:25, Leyzerzon, Simeon G wrote:
> whereas this code in template: (the only difference is in placement of
> #if directive [...]
> 	#set($numberOfColumns = $imperial.size())

Try:

	#set($numberOfColumns = $imperial.size())##

and see if that clears things up for you. I had a similar issue and that
fixed everything. I like readable templates too :)

Dave



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