Hi folks,
I'm using an ERB template to write out a chunk of config file. The key
line of the template is this:
members=<% @members.each_pair do |key, value| -%><%= key -%>;<%=
value['service'] -%>;<%= value['opt'] -%>, <% end %>
and it produces this output:
members=
radius-local01.example.com;RADIUS;&,
radius-local02.example.com;RADIUS;&,
radius-local03.example.com;RADIUS;&,
However, both the 'service' and 'opt' tags are optional so I wrapped
them in conditionals like this:
members=<% @members.each_pair do |key, value| -%><%= key -%><% if
value['service'] %>;<%= value['service'] %><% end %><% if value['opt']
%>;<%= value['opt']%><% end %>, <% end %>
But this resulted in value['service'] being printed as a literal string.
What have I done wrong?
members=
db1.example.com;value['service'];value['opt'],
db2.example.com;value['service'];value['opt'],
db3.example.com;value['service'];value['opt'],
Any hints would be appreciated!
Thanks,
Jonathan
--
Jonathan Gazeley
Senior Systems Administrator
IT Services
University of Bristol