Reputation: 576
I am new to Sinatra.
I work currently on a project that is supposed to use a array,
for example: ary = ['a','b','c']
to covert it into an HTML table (possible using an .erb file).
The table should have a single column with as many rows, as there are strings (dynamic).
for example:
I don't really have a clue how to do that and I tried code from similar projects, that didn't work. I hope its even possible to do.
Upvotes: 3
Views: 3231
Reputation: 16730
In the controller do
get '/something' do
@ary = ['a','b','c']
erb :'something'
end
In the view named something you can do
<table>
<% @ary.each do |elem| %>
<tr>
<td>
<%= elem %>
</td>
</tr>
<% end %>
</table>
Upvotes: 3