如何修复此 ruby 模板以修复结果文件的格式?
How do I fix this ruby template to fix formatting of resulting file?
我正在尝试使用 puppet 在我的系统上写一个文件,声明如下:
file { '/etc/salt/grains':
ensure => present,
content => template('pp_salt_manager/grains.erb'),
}
这是我非常短的 .erb 文件:
<% @machine_info.each do |key, value| %>
<%= "#{key}: #{value}" %>
<% end %>
作为参考,这是 machine_info:
$machine_info = {'deployment' => 'c7', 'local' => 'US', 'env' => 'stable'}
我的问题是,这是输出文件:
_ # Empty line
deployment: c7
_ # Another empty line
local: US
_ # Once again, an empty line
env: stable
如何让它看起来像这样:
deployment: c7
local: US
env: stable
提前致谢!
使用“-%>”而不是“%>”关闭可能有帮助:
<% @machine_info.each do |key, value| -%>
<%= "#{key}: #{value}" %>
<% end -%>
这里是人偶文档的 link:
https://docs.puppetlabs.com/guides/templating.html#trim-mode
我正在尝试使用 puppet 在我的系统上写一个文件,声明如下:
file { '/etc/salt/grains':
ensure => present,
content => template('pp_salt_manager/grains.erb'),
}
这是我非常短的 .erb 文件:
<% @machine_info.each do |key, value| %>
<%= "#{key}: #{value}" %>
<% end %>
作为参考,这是 machine_info:
$machine_info = {'deployment' => 'c7', 'local' => 'US', 'env' => 'stable'}
我的问题是,这是输出文件:
_ # Empty line
deployment: c7
_ # Another empty line
local: US
_ # Once again, an empty line
env: stable
如何让它看起来像这样:
deployment: c7
local: US
env: stable
提前致谢!
使用“-%>”而不是“%>”关闭可能有帮助:
<% @machine_info.each do |key, value| -%>
<%= "#{key}: #{value}" %>
<% end -%>
这里是人偶文档的 link: https://docs.puppetlabs.com/guides/templating.html#trim-mode