I'm trying to figure out a way to take a Ruby array and create an HTML table. The array is dynamic, its contents change depending on user options and inputs so the HTML tables also need to be dynamic.
The array look something like this:
array = [[a, 1, 2 ,3], [a, 1, 2 ,3], [a, 1, 2 ,3], [b, 1, 2 ,3], [b, 1, 2 ,3], [b, 1, 2 ,3], [c, 1, 2 ,3]]
What I would like to do is first group or split the array in the following way (though this might not be necessary, I don't know).
array1 = [[a, 1, 2 ,3], [a, 1, 2 ,3], [a, 1, 2 ,3]]
array2 = [[b, 1, 2 ,3], [b, 1, 2 ,3], [b, 1, 2 ,3]]
array3 = [[c, 1, 2 ,3]]
Then outputting each of the new arrays in a separate HTML tables, where a
, b
, c
could be like a header/title and then sub element would be a new row to the that table. In short I'd like to be able to control where each element is placed in the table.
I know my description probably isn't too clear but this is way beyond my very limited skill set and even difficult to explain what I want to achieve. :)
edit: here's my attemp at visualizing what I'm trying to accomplish...