What's the difference between eruby and erb? What considerations would drive me to choose one or the other?
My application is generating config files for network devices (routers, load balancers, firewalls, etc.). My plan is to template the config files, using embedded ruby (via either eruby or erb) within the source files to do things like iteratively generate all the interface config blocks for a router (these blocks are all very similar, differing only in a label and an IP address). For example, I might have a config template file like this:
hostname sample-router
<%=
r = String.new;
[
["GigabitEthernet1/1", "10.5.16.1"],
["GigabitEthernet1/2", "10.5.17.1"],
["GigabitEthernet1/3", "10.5.18.1"]
].each { |tuple|
r << "interface #{tuple[0]}\n"
r << " ip address #{tuple[1]} netmask 255.255.255.0\n"
}
r.chomp
%>
logging 10.5.16.26
which, when run through an embedded ruby interpreter (either erb or eruby), produces the following output:
hostname sample-router
interface GigabitEthernet1/1
ip address 10.5.16.1 netmask 255.255.255.0
interface GigabitEthernet1/2
ip address 10.5.17.1 netmask 255.255.255.0
interface GigabitEthernet1/3
ip address 10.5.18.1 netmask 255.255.255.0
logging 10.5.16.26