<%
  # We have to call deep_symbolize_keys because we're often dealing with a
  # parsed JSON document which will have string keys by default, but our
  # components use symbol keys and we want consistency.
  links_hash = content_item.to_h.deep_symbolize_keys[:links] || {}

  organisations = []
  organisations += links_hash[:organisations] || []
  organisations += links_hash[:lead_organisations] || []
  organisations += links_hash[:supporting_organisations] || []
  organisations += links_hash[:worldwide_organisations] || []

  world_locations = links_hash[:world_locations] || []
%>
<% if organisations.any? %>
  <meta name="govuk:analytics:organisations" content="&lt;<%= organisations.map { |link| link[:analytics_identifier] }.join('><') %>&gt;">
<% end %>
<% if world_locations.any? %>
  <meta name="govuk:analytics:world-locations" content="&lt;<%= world_locations.map { |link| link[:analytics_identifier] }.join('><') %>&gt;">
<% end %>

<%
  # We have to call deep_symbolize_keys because we're often dealing with a
  # parsed JSON document which will have string keys by default, but our
  # components use symbol keys and we want consistency.
  links_hash = content_item.to_h.deep_symbolize_keys[:links] || {}
  meta_tags = {}

  organisations = []
  organisations += links_hash[:organisations] || []
  organisations += links_hash[:lead_organisations] || []
  organisations += links_hash[:supporting_organisations] || []
  organisations += links_hash[:worldwide_organisations] || []
  organisations_content = organisations.map{ |link| "<#{link[:analytics_identifier]}>" }.join
  meta_tags["govuk:analytics:organisations"] = organisations_content if organisations_content

  world_locations = links_hash[:world_locations] || []
  world_locations_content = world_locations.map{ |link| "<#{link[:analytics_identifier]}>" }.join
  meta_tags["govuk:analytics:world-locations"] = world_locations_content if world_locations_content
%>
<% meta_tags.each do |name, content| %>
  <meta name="<%= name %>" content="<%= content %>">
<% end %>

Move logic out of template render
Move logic out of template render

Split component into two, a top part that deals with the logic and a
second part that renders HTML.
