Sha256: 695b9d9148092942a411bda415937bb765091ab9df8f9d3aa5f9358a3b46fa75

Contents?: true

Size: 1.33 KB

Versions: 27

Compression:

Stored size: 1.33 KB

Contents

<%
  id ||= "error-summary-#{SecureRandom.hex(4)}"
  title ||= false
  description ||= false
  data_attributes ||= {}
  items ||= []
  title_id ||= "error-summary-title-#{SecureRandom.hex(4)}"
  if items.empty? && !title
    raise ArgumentError, "The error_summary component needs at least one item or a title in order to render."
  end
%>
<%= tag.div(
  class: "gem-c-error-summary govuk-error-summary",
  data: { module: "error-summary" }.merge(data_attributes),
  aria: { labelledby: title_id },
  role: "alert",
  tabindex: -1,
  id: id,
) do %>
  <% if title %>
    <h2 class="govuk-error-summary__title" id="<%= title_id %>">
      <%= title %>
    </h2>
  <% end %>
  <div class="govuk-error-summary__body">
    <% if description %>
      <p><%= description %></p>
    <% end %>
    <% if items.present? %>
      <ul class="govuk-list govuk-error-summary__list">
        <% items.each_with_index do |item, index| %>
          <li class="gem-c-error-summary__list-item">
            <% if item[:href] %>
              <%= link_to item[:text], item[:href], target: item[:target], data: item[:data_attributes] %>
            <% else %>
              <%= tag.span data: item[:data_attributes] do %>
                <%= item[:text] %>
              <% end %>
            <% end %>
          </li>
        <% end %>
      </ul>
    <% end %>
  </div>
<% end %>

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
govuk_publishing_components-17.21.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.20.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.19.1 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.19.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.18.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.17.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.16.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.15.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.14.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.13.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.12.2 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.12.1 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.12.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.11.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.10.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.9.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.8.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.7.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.6.1 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-17.6.0 app/views/govuk_publishing_components/components/_error_summary.html.erb