On 01/16/2014 05:47 PM, paul.le...@complex.com wrote:
I have been trying to create a three level hash to dump into a template,
but the deepest layer of the hash seems to not work.
My hash:
$clusters = {
'Default' => {
'127.0.0.1:11211' => {
'hostname' => '127.0.0.1',
'port' => '11211'
},
},
}
My ERB template (modified for readability):
<% @clusters.sort.map do |k,v| -%>
<% if v.is_a?(Hash) -%>
'<%= k %>'
<% @clusters[k].sort.map do |ki, vi| -%>
<% if vi.is_a?(Hash) -%>
'<%= ki %>'
<% @clusters[ki].sort.map do |kii, vii| -%>
<% if vi and vi != '' -%>
'<%= kii %>' = '<%= vii %>',
<% end -%>
<% end -%>
<% end -%>
<% end -%>
<% end -%>
<% end -%>
You are going through a hash inside a hash, so you have to call the
second sort on the hash inside the hash:
<% @clusters[k][ki].sort.map do |kii, vii| -%>
--
You received this message because you are subscribed to the Google Groups "Puppet
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/52D84849.1050708%40superseb.nl.
For more options, visit https://groups.google.com/groups/opt_out.