<li class="department">
  <h2 id="<%= contact_group.slug %>">
    <%= link_to contact_group, "##{contact_group.slug}", 'data-expand' => "#{contact_group.slug}-elements" %>
  </h2>
  <p>
    <%= contact_group.description %>
  </p>
  <%= link_to 'view all', "##{contact_group.slug}", class: "view-all", 'data-expand' => "#{contact_group.slug}-elements" %>

  <div class="organisations-box" id="<%= contact_group.slug %>-elements">
    <div class="organisations-box-inner">
      <ul>
        <% contact_group.offices.each do |office| %>
          <li>
            <h3>
              <%= link_to office, office_path(office) %>
            </h3>
            <p>
              <%= office.contact.description %>
            </p>
          </li>
        <% end %>
      </ul>
    </div>
  </div>
</li>

<% if contact_group.offices.any? %>
  <li class="department">
    <h2 id="<%= contact_group.slug %>">
      <%= link_to contact_group, "##{contact_group.slug}", 'data-expand' => "#{contact_group.slug}-elements" %>
    </h2>
    <p>
      <%= contact_group.description %>
    </p>
    <%= link_to 'view all', "##{contact_group.slug}", class: "view-all", 'data-expand' => "#{contact_group.slug}-elements" %>

    <div class="organisations-box" id="<%= contact_group.slug %>-elements">
      <div class="organisations-box-inner">
        <ul>
          <% contact_group.offices.each do |office| %>
            <li>
              <h3>
                <%= link_to office, office_path(office) %>
              </h3>
              <p>
                <%= office.contact.description %>
              </p>
            </li>
          <% end %>
        </ul>
      </div>
    </div>
  </li>
<% end %>
Hide contact groups that have no contacts on the contact group page.
Hide contact groups that have no contacts on the contact group page.
