Gobbling mostly happens at the parser level right now.  This means
it's not extensible or configurable.  All you can do is modify the
parser and custom build Engine, modify the input (smart resource
loader), or modify the output (jTidy and friends).

http://wiki.apache.org/velocity/VelocityWhitespaceGobbling
https://issues.apache.org/jira/browse/VELOCITY-253

In my ideal world, the parser would treat the whitespace
preceding/following directives as a node type themselves or perhaps as
a distinct part of the directive nodes, allowing us full freedom to
configure whitespace behavior around directives.  (

In my optimistic world, i'd be perfectly happy for Engine 2.0 to
simply have a modified parser that gobbles more  predictably (i.e.
according to Christoph's very nice rules).

In my practical world, it would even be an improvement to just change
the parser to gobble nothing and leave whitespace management fully to
resource loaders or post-processors like jTidy.

But in reality, no one is doing any of this work, including myself.
Velocity is at the dreaded "good enough" point where no flaw is itchy
enough to inspire much hacking.  :(  But you could be the one! :)


On Wed, Nov 2, 2011 at 12:11 PM, Christopher Schultz
<ch...@christopherschultz.net> wrote:
> Nathan,
>
> On 10/31/11 11:45 AM, Nathan Bubna wrote:
>> In that case, the documentation is wrong.  Leading whitespace is only
>> trimmed from in front of a #set directive that has nothing after it.
>> I'm not aware of any other case where leading whitespace is trimmed.
>
> Is this something that could be extended to directives other than #set?
> I just modified some of my XML-emitting templates to adjust whitespace
> and, especially in loops, tons of extra whitespace is generated. I ended
> up inserting VTL comments to get the job done and still have my
> directives indented properly (or I'd lose my sanity).
>
> Thanks,
> -chris
>
>

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

Reply via email to