All,

Actually, things are a bit weirder in my actual template: sometimes I'm
able to get only a single # of the trailing ## to render in the output.
I'm trying to get that whittled-down to a simpler test case.

I tried using "${foo}##" as reported earlier to get the ## to go away,
but that does not seem to be working in my actual template. Working on it.

Basically, my template looks like a lot of this kind of stuff:

<xml:document>$indent.nl##
$indent.get(2)<xml:sub-element>....</xml:sub-element>$indent.nl##
</xml:document>$indent.nl##

The "indent" reference allows us to enable human-readable, formatted XML
but then also turn that off to reduce the number of useless bytes sent
over the network in production.

There are some conditionals and stuff like that in there, too, and most
of those look like this:

#if(something)
...
#else## (something)
...
#end## (something)

We use those one-line comment things so that we can document which
else/end goes with which if/else.

Odd that sometimes we are getting those extra # or ## at the end of
lines in the output.

Any ideas are appreciated.

Thanks,
-chris

On 8/29/13 1:55 PM, Christopher Schultz wrote:
> All,
> 
> Velocity 1.7, Oracle JDK 1.7.0_25
> 
> I found something odd recently and was able to reduce it to this simple
> test-case:
> 
> $foo##
> $foo.bar##
> $foo.bar.baz##
> 
> Expected output (with foo=null):
> 
> $foo$foo.bar$foo.bar.baz
> 
> Actual output:
> $foo$foo.bar##
> $foo.bar.baz##
> 
> Using {..} around the references makes this example work the way I had
> expected. Also, adding spaced /before/ the ## at the end of the lines
> makes the output look as I had expected.
> 
> Another data point:
> 
> $foo${foo.bar}##
> $foo.bar.baz}##
> 
> (Note trailing } after "baz").
> 
> Yields:
> 
> $foo${foo.bar}$foo.bar.baz}
> 
> I've been using ## at the end of lines where I want to avoid a newline
> in the output for a while... I just noticed this case recently. Is this
> something that /should/ work the way I expect, or am I abusing Velocity
> in this way?
> 
> Thanks,
> -chris
> 

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to