Skip to content

Instantly share code, notes, and snippets.

@ahoward
Created December 20, 2008 22:22
Show Gist options
  • Save ahoward/38439 to your computer and use it in GitHub Desktop.
Save ahoward/38439 to your computer and use it in GitHub Desktop.
def collection_matrix options = {}, &block
collection = options.getopt(:collection, @collection)
matrix = collection.matrix
table_(:class => 'simple collection matrix'){
thead_{
td_{ '-' }
matrix.cols.each do |col|
td_(:class => 'col name'){ h col.name }
end
}
matrix.rows.each do |row|
tr_{
td_(:class => 'row name'){
h [row.name, row.report_type.downcase].join(', ')
}
row.each do |cell|
td_{
block.call(cell)
}
end
}
end
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment