DRYing Things Up

Is there any reason you are doing this as a helper rather than either
a.) a partial or b.) a helper with a partial?

V/r
Anthony Eden

Shai Shefer wrote:

This is the closest I have gotten, can anyone help?

  def render_product_tiles(products, options = {})
    size = options[:size]
    amount = options[:groups]
    "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"
class=\"product_tile_all\">"
    products.in_groups_of(amount) do |row|
      "<tr>"

I don't get it. I didn't know you could generate HTML using unassigned strings like that.

Why aren't you using xml = Builder::XmlMarkup.new ? That would go...

      row.each do |product|

       xml.td :align => :center, :class => "product_tile_#{size}" do

          @product = product

                    xml.div :style => "etc..."
       end

When you finish, extract the accreted string with xml.target!

DRY now becomes a matter of refactoring and squeezing down the xml calls, as raw Ruby. Use my assert_xpath() trick to test that while you squeeze it...

If you don't need this, my post rests in the archives for others to learn from...