Skip to content

Instantly share code, notes, and snippets.

@bronson
Forked from sbr/example.erb
Created October 9, 2009 02:31
Show Gist options
  • Save bronson/205642 to your computer and use it in GitHub Desktop.
Save bronson/205642 to your computer and use it in GitHub Desktop.
<div class="list">
<ul>
<% @items.each do |item| %>
<li class="<%= item_classes_for_user(item, @current_user) %>">
<%= image_tag "/icons/#{item.state}.png" %>
<span class="name">
<%= item.name %>
</span>
</li>
<% end %>
</ul>
</div>
.list
%ul
- @items.each do |item|
%li{ :class => item_classes_for_user(item, @current_user) }
= image_tag "/icons/#{item.state}.png"
%span.name= item.name
# Erector
div :class => "list" do
ul do
@items.each do |item|
li :class => item_classes_for_user(item, @current_user) do
img :src => "/icons/#{item.state}.png"
span item.name, :class => "name"
end
end
end
end
def item_classes_for_user(item, user)
classes = ["item", item.state]
classes << "interesting" if item.interesting_to?(user)
classes
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment