Skip to content

Instantly share code, notes, and snippets.

@epitron
Created September 17, 2012 03:56
Show Gist options
  • Save epitron/18970e86ded35f4478e5 to your computer and use it in GitHub Desktop.
Save epitron/18970e86ded35f4478e5 to your computer and use it in GitHub Desktop.
Demo of "easy_table()" (a DSL for turning a collection of Ruby objects into an HTML table), created for a Rails app in 2006.
<%= easy_table(items, :class=>"table-style1", :tbody_id=>@table_id) do
col("Name") {|o| o.drug_price.name}
col("Qty", :quantity)
col("Price") {|o| number_to_currency(o.price) }
col("Actions") do |o|
link_to image_tag('small/delete.png'),
:action => "return_package_item",
:package_item => o.id,
:id => @order.id
end
end %>
<% for package in @order.packages %>
<h2>Package for <%= package.pharmacy.name %> <%= package.pharmacy.country.flag_image_tag %></h2>
<%= render :partial => "table_of_package_items", :locals => {:items => package.items} %>
<div id="package<%= package.id %>_totals">
<%= render :partial => "package_totals", :locals => {:package => package} %>
</div>
<h3>current status: <%= package.state %></h3>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment