Re: Unexpected template parsing issue
Christopher Schultz <[email protected]> Thu, 29 Aug 2013 14:04:27 -0400
| Newsgroups | gmane.comp.jakarta.velocity.user |
|---|---|
| Message-ID | <[email protected]> |
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
>
signature.asc
(application/pgp-signature, 938 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBCAAGBQJSH40rAAoJEBzwKT+lPKRYY0QP/0Fi7BtN1uszFAlV3SDnt1y3 ecV8PCXWi5jbjvHZJMI3mVnD+0vZI2aa96kt1FcyVFB1ONtuTvQ2Sb86gWtphdqo iHj/TNnr4i6IzdcRzW0FG5szjDGz9K5O+q2rAuP6Cy6Jpb9LWhS0v3AtYxU5NXR2 U4q8i+3giR+CIgt7aM/Mut+GCMDOOho9BMJscY/UC9EpSOB5y+Fuj6Z6Ug86Fz5f 5vQpqMkNtl9HWtAR3g1QcjUBqx4TyVb1+ADTrG3dxEdojms7dGJ1g/OqpZS33QEr QODtiTMacoHKfLKxf+hv0lOEerAbSJvuhrPR3cqSrzDsFOmlXNMifC5619pWS9Re 28rcFfncEmwp5F81p4qB5IcdrcIJIP93dkM8gBFLm68TZ4kQGkwoVWuHkserEvNs I5fvBsLf9fYBgfyIlcC5DW6d55EhFn1VysCV2O/PQ+AEU4/ERshri7eHu8Iy4XJA m9tVykThv7JnADClcM+ebBonyBY+7Vv1RkQjLL6jFmu3HGxPwjZ6SNbHNiTaP8dc xs+Dz7C0ergfdBJznABRsy4SVLmfBxv7q3t+IYM+Ez0lR1G9BFaDIlxWqPxuXzd0 JQwkB8Y+GmJf9A8xOGUlmYVH+V1omVrv0Yvro37TaQnqAOxanaABo4Xz1TgrJ/Yp KumajAW7fib+zXGIv0/I =nUDJ -----END PGP SIGNATURE-----