filling in the helper function bits + using "html_safe" method since I am on Rails 3

This commit is contained in:
Dan Buch 2011-08-10 22:32:18 -04:00
parent cb8e89de30
commit 066433a22d
2 changed files with 8 additions and 2 deletions

View File

@ -1,2 +1,9 @@
require 'sha1'
module ListHelper module ListHelper
def create_li(item, i)
%{<li class="#{ i % 2 == 0 ? 'even' : 'odd' }">#{i}:
#{SHA1.new(item.object_id.to_s)}</li>}
end
end end

View File

@ -1,6 +1,5 @@
<ul style="font-family:monospace;"> <ul style="font-family:monospace;">
<% @list.each_with_index do |item, i| %> <% @list.each_with_index do |item, i| %>
<li class="<%= i % 2 == 0 ? 'even' : 'odd' %>"><%= i %>: <%= create_li(item, i).html_safe %>
<%= SHA1.new(item.object_id.to_s) %></li>
<% end %> <% end %>
</ul> </ul>