<%=
  render partial: 'content/contexts/relation', locals: {
    content_type: Religion,
    content: content,
    relation_class: Artifactship,
    relation_class_id: :artifact_id,
    relation_text: :artifact_of
  }
%>

<%=
  render partial: 'content/contexts/relation', locals: {
    content_type: Group,
    content: content,
    relation_class: GroupEquipmentship,
    relation_class_id: :equipment_id,
    relation_text: :equipment_for
  }
%>

<%=
  render partial: 'content/contexts/relation', locals: {
    content_type: Group,
    content: content,
    relation_class: KeyItemship,
    relation_class_id: :key_item_id,
    relation_text: :key_item_for
  }
%>

<% scenes = SceneItemship.where(scene_item_id: content.id).map(&:scene).compact.select { |content| content && content.readable_by?(current_user || User.new) } %>
<% if scenes.any? %>
  <div class="col s12 m6 l4">
    <%= render partial: 'content/cards/in_universe_content_list', locals: {
      content_type: :scene,
      content_list: scenes,
      card_title: "Appears in #{pluralize(scenes.count, 'scene')}"
    } %>
  </div>
<% end %>

<% @references.each do |content_type, relations| %>
  <% next unless relations.any? %>
  <%
  card_title = if relations.count == 1
    if relations.first.first.include? '<plural>'
      relations.first.first
    else
      [
        relations.first.first,
        ' ',
        pluralize(relations.count, "#{content_type.to_s.singularize}")
      ].join
    end
  else
    [
      'Related to ',
      pluralize(relations.count, "other #{content_type.to_s.singularize}")
    ].join
  end
  %>
  <div class="col s12 m6 l4">
    <%= render partial: 'content/cards/content_relation_list', locals: {
      content_type: content_type,
      relations:    relations,
      card_title:   card_title
    } %>
  </div>
<% end %>
