I have a list containing maps that I want to loop through.
[
%{book_type: "Fiction", total: 5},
%{book_type: "History", total: 45},
%{book_type: "Romance", total: 90},
%{book_type: "Drama", total: 7}
]
i want to loop on this html tds
<tr> <td class="text-left border-top" style="font-weight: normal !important;">books</td> <td class="border-top"style="font-weight: normal !important;">Fiction</td> <td class="border-top"style="font-weight: normal !important;">History</td> <td class="border-top"style="font-weight: normal !important;">Romance</td> <td class="border-top"style="font-weight: normal !important;">Drama</td> <tr> <td style="font-weight: normal !important;">Total</td> <%= for book <-@books do %> <td style="font-weight: normal !important;"><%= book.total %></td> <td style="font-weight: normal !important;"><%= book.total %></td> <td style="font-weight: normal !important;"><%= book.total %></td> <td style="font-weight: normal !important;">0<%= book.total %></td> <% end %> </tr>
I want to produce something like this
books Fiction History Romance Drama
Total 5 45 90 7
how do I go about it?