velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Reck <apa...@recks.org>
Subject Re: unwanted whitespace
Date Wed, 08 Dec 2004 08:27:09 GMT
Hi Rob, (and everyone else trying to understand velocitys whitespace handling...

Check the Wiki page http://wiki.apache.org/jakarta-velocity/VelocityWhitespaceGobbling
on this subject. The so called "VelocityWhitespaceGobbleChristophsWay"
should be called VelocityWhitespaceGobbleStructuredTemplates".

Please vote for the structured templates approach, and lets see
if we can gain momemtum for a future release.

Could we get a pointer to the Velocity-Wiki area on the entry
jakarta-velocity page?

Some other discussions on this subject was found in the following
threads:
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=velocity-user@jakarta.apache.org&msgId=1421375
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=velocity-user@jakarta.apache.org&msgId=1681773

more embedded...

Rob Butler wrote:
> Hello all,
> 
> I read the velocity docs, and according to them I can
> write the function below in two ways:
> 
> Method 1:
>  
> #macro(displayPositiveOnly $val)

The next whitespaces are currently not gobbled by velocity,
which causes extra inentation of $val.
  vvvvvvv
> 	#if($val >= 0)
                       ^
The EOL after directives is a gobbled whitespace.
> 		$val
> 	#end
> #end
> 
> Method 2:
> 
> #macro(displayPositiveOnly $val)#if($val >=
> 0)$val#end#end

The following 2 forms will output exactly the same as Method 2:

Method 3:

#macro(displayPositiveOnly $val)#*
	*##if($val >= 0)#*
		*#$val#*
	*##end
#end


Method 4:

#macro(displayPositiveOnly $val)##
#*	*##if($val >= 0)##
#*		*#$val##
#*	*##end##
#end

> 
> And either way the output will be the same.  I have
> tried both ways of defining the macro, and indeed both
> ways have the same output.  However, both ways also
> add about half a dozen extra spaces in front of $val,
> which causes a problem.  Does Velocity have a bug in
> it's white space removal?  Am I doing something wrong?

yes,

> 
> I am using Velocity version 1.4 that shipped with the
> SpringFramework 1.1.2.  $val is an integer.
> 
> Thanks!
> Rob

Cheers,
Chirstoph

---------------------------------------------------------------------
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