I need some help with erb templates, I can't seem to get my head around passing an array and then iterating over it. My problem is this. I want to pass a few arrays: `
device => ["eth0", "br0"],
ipaddr => ["192.168.12.166", "192.168.12.199"],
netmask => ["255.255.255.0", "255.255.255.0"],
hwaddr => '',
network => '',
gateway => ["192.168.12.254", "192.168.12.204"],
To a template that iterates over each item in the array and prints it out:
auto <%= device %> inet static
address <%= ipaddr %>
netmask <%= netmask %>
broadcast <%= broadcast %>
gateway <%= gateway %>
As far as I can get so far is figuring out that I need to do something with device.each |device| puts device
, but I don't know what the syntax is supposed to look like.
I believe you can tell what I'm trying to do from these snippets, and then you might understand that the entries need to be seperate, and not interpolated.
Any help you can offer would be appreciated. I know I should be trying things out in irb and figuring them out from there, which is what I'm reading up on now.
Thanks!