So this might be a little confusing but bear with me. In short I want to loop over all attributes with a certain key value and then insert them into a template if the values ar
What you probably meant was:
<% node['elasticsearch']['default'].each do |key, value| -%>
<% unless value.empty? -%>
<%= key %>=<%= value %>
<% end %>
<% end %>
When iterating over a Hash
, you go over its key-value pairs. So for the first iteration, key
will be 'ES_USER'
, and value
will be ''
(which is not nil
...).
Next you check that the value is not blank?, and print out the key=value
line.