% if @breadcrumbs_items&.length %>
<% shortened = @breadcrumbs_items.length > 4 %>
<% if shortened %>
<% first_breadcrumb_item = @breadcrumbs_items.shift
last_breadcrumb_items = @breadcrumbs_items.pop(2) %>
<%= link_to(first_breadcrumb_item[:label], first_breadcrumb_item[:url],
class: "breadcrumbs-link",
title: first_breadcrumb_item[:label]) %>
<%= image_tag "icon_small/navigate_next.svg",
alt: "navigate next",
class: "navigate_next" %>
•••
<%= image_tag "icon_small/navigate_next.svg",
alt: "navigate next",
class: "navigate_next" %>
<% item = last_breadcrumb_items.first %>
<%= link_to(item[:label], item[:url],
class: "breadcrumbs-link",
title: item[:label]) %>
<%= image_tag "icon_small/navigate_next.svg",
alt: "navigate next",
class: "navigate_next" %>
<% last_item = last_breadcrumb_items.last %>
<%= last_item[:label] %>
<% else %>
<% template_paths = [/^\/protocols\/\d+$/, /^\/label_templates\/\d+$/] %>
<% if template_paths.any? { |pattern| request.path.match?(pattern) }%>
<% last_breadcrumb_items = @breadcrumbs_items.pop(2) %>
<% else %>
<% last_item = @breadcrumbs_items.pop %>
<% end %>
<% @breadcrumbs_items.each do |item| %>
<%= link_to(item[:label], item[:url],
class: "breadcrumbs-link",
title: item[:label]) %>
"
alt="navigate next"
class="navigate_next">
<% end %>
<% if last_breadcrumb_items %>
<%= last_breadcrumb_items.first[:label] %>
"
alt="navigate next"
class="navigate_next">
<%= last_breadcrumb_items.last[:label] %>
<% end %>
<% if last_item %>
<%= last_item[:label] %>
<% end %>
<% end %>
<% end %>