18F/identity-idp

View on GitHub
app/views/report_mailer/tables_report.html.erb

Summary

Maintainability
Test Coverage
<%#
- @message: text to put in the beginning of the email
- @reports: an array of EmailableReport
%>
<%= @message %><br>
<% @reports.each do |report| %>
  <% header, *rows = report.table %>
  <%# Allow nil title if a subtitle is set %>
  <% if report.title && report.title != report.subtitle %>
    <h2><%= report.title %></h2>
  <% end %>
  <% if report.subtitle %>
    <h3><%= report.subtitle %></h3>
  <% end %>

  <table class="usa-table">
    <thead>
      <tr>
        <% header.each do |head| %>
          <th scope="col"><%= head %></th>
        <% end %>
      </tr>
    </thead>
    <tbody>
      <% rows.each do |row| %>
        <tr>
          <% row.each do |cell| %>
            <td <%= cell.is_a?(Numeric) ? 'class=table-number' : nil %> >
              <% if cell.is_a?(Float) && report.float_as_percent? %>
                <%= number_to_percentage(cell * 100, precision: report.precision || 2) %>
              <% else %>
                <%= number_with_delimiter(cell) %>
              <% end %>
            </td>
          <% end %>
        </tr>
      <% end %>
    </tbody>
  </table>
<% end %>