velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Avoiding whitespace
Date Mon, 31 Oct 2011 14:29:02 GMT

The User Guide says that "Velocity's behavior is to gobble-up excess
whitespace" and offers this example:

Velocity's behaviour is to gobble up excess whitespace. The preceding
directive can be written as:

Send me
#set( $foo = ["$10 and ","a pie"] )
#foreach( $a in $foo )

or as

Send me
#set($foo       = ["$10 and ","a pie"])
                 #foreach           ($a in $foo )$a
         #end please.

In each case the output will be the same.

I'm not observing this behavior. In my templates, the trailing
whitespace after a directive on a line (usually just a newline) appears
to be trimmed, but leading whitespace is preserved. So, the output from
the second example looks like this:

Send me
                 $10 and
         a pie

(note the leading whitespace before "$10 and", etc. which you may not be
able to see if you are viewing this message in HTML mode).

Am I missing some kind of configuration parameter? I don't appear to
have anything in my configuration that has anything to do with whitespace.

Is the documentation wrong? Or am I just mis-reading it?

I know the issue of whitespace comes-up a lot, and I'm sorry to add to
the never-ending discussion.


View raw message