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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With