From 2d2e237a7c92559549ee7688ec0a2ad8a41ce029 Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Thu, 10 May 2018 10:02:54 +0000 Subject: [PATCH] Move code from component into a helper --- .../components/_subscription-links.html.erb | 43 +++++--------- lib/govuk_publishing_components.rb | 1 + .../presenters/subscription_links_helper.rb | 57 +++++++++++++++++++ 3 files changed, 71 insertions(+), 30 deletions(-) create mode 100644 lib/govuk_publishing_components/presenters/subscription_links_helper.rb diff --git a/app/views/govuk_publishing_components/components/_subscription-links.html.erb b/app/views/govuk_publishing_components/components/_subscription-links.html.erb index dd3d2d9483..78a28c048d 100644 --- a/app/views/govuk_publishing_components/components/_subscription-links.html.erb +++ b/app/views/govuk_publishing_components/components/_subscription-links.html.erb @@ -1,57 +1,40 @@ <% - email_signup_link ||= false - email_signup_link_text ||= t("govuk_component.subscription_links.email_signup_link_text", default: "Get email alerts") - email_signup_link_data_attributes ||= false - - feed_link ||= false - feed_link_text ||= t("govuk_component.subscription_links.feed_link_text", default: "Subscribe to feed") - feed_link_box_value ||= false - feed_link_data_attributes ||= {} - - tracking_is_present = true if email_signup_link_data_attributes || feed_link_data_attributes.any? - brand ||= false brand_helper = GovukPublishingComponents::Presenters::BrandHelper.new(brand) - - if feed_link_box_value - feed_link = "#" - feed_box_id = SecureRandom.hex(2) - feed_link_data_attributes[:controls] = "feed-reader-#{feed_box_id}" - feed_link_data_attributes[:expanded] = "false" - end + sl_helper = GovukPublishingComponents::Presenters::SubscriptionLinksHelper.new(local_assigns) %> -<% if email_signup_link || feed_link || feed_link_box_value %> +<% if sl_helper.component_data_is_valid? %>