I have an array, which is loaded from a database. It is in the following format:
["aaa:bbb", "ccc:ddd"]
And need to build an HTML definition list from the array:
<dl>
<dt>aa</dt>
<dd>bb</dd>
<dt>cc</dt>
<dd>dd</dd>
</dl>
Looks easy, isn't it?
I wanted to create a helper, which would go through the array, split the items on the :
's, and enclose them in tags:
<%= build_def_list(array) %>
However, I have encountered a problem. Namely, when I call a Rails helper from a view, all of its content goes to the output. That is, when I declare a variable within the body of a function and assign a value to it, the variable instantly goes to the output. Is there a way to suppress the printing of everything inside the body of a function?
UPD
Seriously, how to make this with helper?..
<dl>
<% deflist.each do |item| %>
<dt><%= item.split(':').at(0) %>:</dt>
<dd><%= item.split(':').at(1) %></dd>
<% end %>
</dl>