<%- cl_helper = GovukPublishingComponents::Presenters::ContentsListHelper.new(local_assigns) aria_label ||= t("components.contents_list.contents") format_numbers ||= false brand ||= false brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand) title_fallback = t("components.contents_list.contents", locale: I18n.locale, fallback: false, default: "en") classes = cl_helper.classes classes << brand_helper.brand_class -%> <% if cl_helper.contents.any? %> <%= content_tag( :nav, class: classes, "aria-label": aria_label, role: "navigation", data: { module: "track-click" } ) do %> <%= content_tag( :h2, {class: "gem-c-contents-list__title"}.merge( title_fallback == "en" ? {:lang => "en",} : {} ) ) do %> <%= t("components.contents_list.contents") %> <% end %>
    <% contents.each.with_index(1) do |contents_item, position| %>
  1. > <% link_text = format_numbers ? cl_helper.wrap_numbers_with_spans(contents_item[:text]) : contents_item[:text] %> <%= link_to_if !contents_item[:active], link_text, contents_item[:href], class: "gem-c-contents-list__link govuk-link #{brand_helper.color_class}", data: { track_category: 'contentsClicked', track_action: "content_item #{position}", track_label: contents_item[:href], track_options: { dimension29: contents_item[:text] } } %> <% if contents_item[:items] && contents_item[:items].any? %>
      <% contents_item[:items].each.with_index(1) do |nested_contents_item, nested_position| %>
    1. > <%= link_to_if !nested_contents_item[:active], nested_contents_item[:text], nested_contents_item[:href], class: "gem-c-contents-list__link govuk-link #{brand_helper.color_class}", data: { track_category: 'contentsClicked', track_action: "nested_content_item #{position}:#{nested_position}", track_label: nested_contents_item[:href], track_options: { dimension29: nested_contents_item[:text] } } %>
    2. <% end %>
    <% end %>
  2. <% end %>
<% end %> <% end %>