Sha256: 99dd125891cd6ad6540856674d915d8115db1c36166db0e6701853aeacd662a8

Contents?: true

Size: 1.09 KB

Versions: 93

Compression:

Stored size: 1.09 KB

Contents

module GovukPublishingComponents
  module Presenters
    class InterventionHelper
      def initialize(local_assigns)
        @accessible_text_suffix = I18n.t("components.intervention.accessible_link_text_suffix")
        @query_string = local_assigns[:query_string]
        @suggestion_link_text = local_assigns[:suggestion_link_text]
        @suggestion_link_url = local_assigns[:suggestion_link_url]
      end

      def accessible_text
        @suggestion_link_text << @accessible_text_suffix unless @suggestion_link_text.include?(@accessible_text_suffix)

        @suggestion_link_text
      end

      def dismiss_link
        if @query_string.present?
          "#{@query_string}&hide-intervention=true"
        else
          "?hide-intervention=true"
        end
      end

      def security_attr
        rel = "noopener noreferrer"
        rel << " external" unless @suggestion_link_url.start_with?("/", "https://gov.uk", "https://www.gov.uk")

        rel
      end

    private

      attr_reader :accessible_text_suffix, :query_string, :suggestion_link_text, :suggestion_link_url
    end
  end
end

Version data entries

93 entries across 93 versions & 1 rubygems

Version Path
govuk_publishing_components-35.2.0 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-35.1.1 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-35.1.0 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-35.0.0 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.14.0 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.13.0 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.12.0 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.11.0 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.10.1 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.10.0 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.9.1 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.9.0 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.8.1 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.8.0 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.7.1 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.7.0 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.6.0 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.5.1 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.5.0 lib/govuk_publishing_components/presenters/intervention_helper.rb
govuk_publishing_components-34.4.2 lib/govuk_publishing_components/presenters/intervention_helper.rb