Sha256: 834ae9eb384e056afe6b495886e9a45a2fd6c3fe6b89071fb8c8e39a9a9bc188

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 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] %>
            <% else %>
              <%= item[:text] %>
            <% end %>
          </li>
        <% end %>
      </ul>
    <% end %>
  </div>
<% end %>

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
govuk_publishing_components-16.29.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.28.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.27.1 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-16.27.0 app/views/govuk_publishing_components/components/_error_summary.html.erb