我有一个木偶模板,它在内循环的每次迭代中添加一个额外的换行符。模板如下:
;; THIS FILE IS MANAGED BY PUPPET
; <%= @comment %>
[production]
<%-
@data.sort.map do |provider,attributes|
@data[provider].sort.map do |key,value| -%>
<%= provider %>.<%= key %> = "<%= value %>"
<%- end
end -%>
输出类似于:
;; THIS FILE IS MANAGED BY PUPPET
; Some random config file
[production]
provider1.a="1"
provider1.a="2"
provider1.a="3"
provider2.a="4"
provider2.a="5"
provider2.a="6"
据我所知,该模板应该会抑制其他换行符。我错过了什么吗?
答案 0 :(得分:1)
尝试添加&#39; - &#39;迭代中的值。
"<%= value %>"
=&gt; "<%= value -%>"
更改为:
;; THIS FILE IS MANAGED BY PUPPET
; <%= @comment %>
[production]
<%-
@data.sort.map do |provider,attributes|
@data[provider].sort.map do |key,value| -%>
<%= provider %>.<%= key %> = "<%= value -%>"
<%- end end -%>