Reputation: 1605
Recently we migrated our application from Velocity 1.7 to 2.0. But after the migration. I see a strange problem, that the output is chomping new lines and merging lines. This happens when we do a parseTemplate()
call.
For Example, here is the piece of code that is causing the problem.
#if ($bvoipData && $bvoipConfigType == "TDM")
call rsvp-sync
!
dial-peer cor custom
!
#parseTemplate ("IPFlex/VoiceDialPeer.vm")
sip-ua
.
.
.
.
#end
With the previous version, the output came in like:
dial-peer hunt 1
!
sip-ua
retry invite 2
no cdp run
!
But with Velocity 2.0, I get the output as:
dial-peer hunt 1
!sip-ua
retry invite 2
no cdp run
!
I would expect the sip-ua to show up in a new line, rather it just merges it to the previous line.
The line:
dial-peer hunt 1
!
comes from the template IPFlex/VoiceDialPeer.vm
.
Not sure if there is some extra configuration that was introduced as a part of the 2.0 release that I probably missed. Any pointers on this would be really helpful.
Upvotes: 0
Views: 554
Reputation: 4130
Velocity 2.0 introduces the notion of space gobbling.
I guess you would need to add
parser.space_gobbling = bc # stands for 'backward-compatible'
to your configuration.
More generally, to maximize backward compatibility with 1.7, you would need to set the following configuration:
# No automatic conversion of methods arguments
introspector.conversion_handler.class = none
# Use backward compatible space gobbling
parser.space_gobbling = bc
# Have #if($foo) only returns false if $foo is false or null
directive.if.empty_check = false
# Allow '-' in identifiers (since 2.1)
parser.allow_hyphen_in_identifiers = true
# Enable backward compatibility mode for Velocimacros
velocimacro.enable_bc_mode = true
# When using an invalid reference handler, also include quiet references (since 2.2)
event_handler.invalid_references.quiet = true
# When using an invalid reference handler, also include null references (since 2.2)
event_handler.invalid_references.null = true
# When using an invalid reference handler, also include tested references (since 2.2)
event_handler.invalid_references.tested = true
as stated on the upgrading page.
Upvotes: 0