簡體   English   中英

Velocity 刪除新行 (Apache Velocity 2.0)

[英]Velocity Removing New Line (Apache Velocity 2.0)

最近,我們將應用程序從 Velocity 1.7 遷移到了 2.0。 但是遷移之后。 我看到一個奇怪的問題,output 正在咀嚼新行和合並行。 這發生在我們調用parseTemplate()時。

例如,這是導致問題的一段代碼。

#if ($bvoipData && $bvoipConfigType == "TDM")
    call rsvp-sync
    !
    dial-peer cor custom
    !
    #parseTemplate ("IPFlex/VoiceDialPeer.vm")
    sip-ua
    .
    .
    .
    .

#end

在以前的版本中,output 的出現如下:

dial-peer hunt 1

!
sip-ua

 retry invite 2

 no cdp run

!

但是使用 Velocity 2.0,我得到 output 為:

dial-peer hunt 1

!sip-ua

 retry invite 2

 no cdp run

!

我希望 sip-ua 出現在新行中,而不是將其合並到上一行。

該行:

dial-peer hunt 1

!

來自模板IPFlex/VoiceDialPeer.vm

不確定是否有一些我可能錯過的作為 2.0 版本的一部分引入的額外配置。 對此的任何指示都會非常有幫助。

Velocity 2.0 引入了空間吞噬的概念。

我想你需要添加

parser.space_gobbling = bc # stands for 'backward-compatible'

到你的配置。

更一般地說,為了最大限度地向后兼容 1.7,您需要設置以下配置:

# 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

升級頁面所述。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM