velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Butler <crodste...@yahoo.com>
Subject Re: unwanted whitespace
Date Wed, 08 Dec 2004 14:21:31 GMT
Christoph,

I tried to edit the page you suggested, but it said I
am not allowed to edit that page, and the bottom of
the page says "Immutable page".  Do I need to login or
something?

As for whitespace handling I can see some situations
(maybe not web based) where you would want to output
white space from inside a macro, so instead of always
gobbling every bit of white space there should be some
directives to control it in each macro.  The default
should probably be to gobble all white space
everywhere in the macro, and then create a directive
like:

#preserveWhitespace
white    space   is   preserved in here   .
#endPreserveWhitespace

This way, when you define a macro all whitespace
before/after the #preserveWhitespace directive is
gobbled, but you have the option of putting white
space out if you need to.  That would be the best in
my opinion.

Later
Rob

--- Christoph Reck <apache@recks.org> wrote:

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



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail

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