Skip to content

Commit

Permalink
Fix issue with incorrectly closed div tags
Browse files Browse the repository at this point in the history
When there was only one item the div.row wasn't getting closed
correctly, which was breaking the page layout. This change uses
Enumerable#each_slice rather than the array index to correctly close
tags.
  • Loading branch information
chrismytton committed Jun 29, 2016
1 parent 0d47659 commit 5c3e9cb
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions views/report.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
</p>

<div class="report-legislatures">
<% @country.legislatures.each_with_index do |legislature, i|
stats = @legislature_stats[legislature.slug][:totals]
total = stats[:overall][:total].to_f
male = stats[:overall][:male].to_f
female = stats[:overall][:female].to_f
total = male + female
%>
<% if i % 2 == 0 %>
<% @country.legislatures.each_slice(2) do |legislatures| %>
<div class="row">
<% end %>
<% legislatures.each do |legislature| %>
<%
stats = @legislature_stats[legislature.slug][:totals]
total = stats[:overall][:total].to_f
male = stats[:overall][:male].to_f
female = stats[:overall][:female].to_f
total = male + female
%>
<div class="col-sm-6">

<a class="list__item country" href="#<%= legislature.slug %>" data-scroll-to-id>
Expand All @@ -42,10 +42,9 @@
</a>

</div>
<% if i % 2 != 0 %>
<% end %>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
Expand Down

0 comments on commit 5c3e9cb

Please sign in to comment.