t0mmyt
t0mmyt

Reputation: 513

puppet erb extra newline

I have a puppet template that is adding an extra newline on each iteration of the inner loop. The template is as follows:

;; 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 -%>

The output is something along the lines of:

;; 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"

As far as I can tell, that template should be suppressing the additional newlines. Am I missing something?

Upvotes: 1

Views: 5882

Answers (1)

Amadu Bah
Amadu Bah

Reputation: 2989

try add '-' value in iteration. "<%= value %>" => "<%= value -%>"

Change to:

;; 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 -%>

Upvotes: 2

Related Questions