<% results.each do |protocol| %> <% has_description = protocol.description.present? && !protocol.description.empty? %> <% has_authors = protocol.authors.present? && !protocol.authors.empty? %> <% has_keywords = protocol.in_repository? && protocol.protocol_keywords.count > 0 %>
<%= render partial: "search/results/partials/protocol_text.html.erb", locals: { protocol: protocol, query: search_query } %>
<% if has_description || has_authors || has_keywords %>

<% if has_description %> <%=t "search.index.description" %> <%= highlight protocol.description, search_query.strip.split(/\s+/) %> <% if has_authors || has_keywords %>
<% end %> <% end %> <% if has_authors %> <%=t "search.index.authors" %> <%= highlight protocol.authors, search_query.strip.split(/\s+/) %> <% if has_keywords %>
<% end %> <% end %> <% if has_keywords %> <%=t "search.index.keywords" %> <% protocol.protocol_keywords.each_with_index do |kw, i| %> <%= highlight kw.name, search_query.strip.split(/\s+/) %> <% if i < protocol.protocol_keywords.count - 1 %> ,  <% end %> <% end %> <% end %>

<% end %>

<%=t "search.index.created_at" %> <%=l protocol.created_at, format: :full %>
<% if protocol.in_module? %> <%=t "search.index.module" %> <%= render partial: "search/results/partials/my_module_text.html.erb", locals: { my_module: protocol.my_module } %>
<%=t "search.index.project" %> <%= render partial: "search/results/partials/project_text.html.erb", locals: { project: protocol.my_module.project } %>
<% end %> <%=t "search.index.organization" %> <%= render partial: "search/results/partials/organization_text.html.erb", locals: { organization: protocol.organization } %>


<% end %>