<ul>
<% for file in @files %>
<li><%= file %></li>
<% end %>
</ul>
output :
but if i want to use enumerator :
<% @files.each{|file| file} %>
output : ['file1', 'file2']
I can not get the output as a <\\li> list.
My question is is it possible to get the list output using enumeration? if so how?? I am a beginner at rails.
<% @files.each do |file| %>
<li><%= file %></li>
<% end %>
For the sake of one liner, you could do:
<%=raw @files.map {|file| content_tag(:li, file)}.join %>
#mix
<% @files.each do |file| %> <%= content_tag(:li, file) %> <% end %>
But really , don't !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.