From f4223d2f97bbec83088fe5ae9378189f78428f3a Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Mon, 2 Sep 2024 16:18:40 +0100 Subject: [PATCH] Adjust notifications helper --- app/helpers/notifications_helper.rb | 36 +++++++++++++---------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 5780846c0..9f82a3d3d 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -16,32 +16,28 @@ module NotificationsHelper end def render_for_banner(title) - @@banner_renderer ||= NotificationTitleRenderer.new({ invert_link_colour: true, bold_all_text: true }) - @@banner_markdown ||= Redcarpet::Markdown.new(@@banner_renderer, no_intra_emphasis: true) - @@banner_markdown.render(title) + banner_renderer ||= NotificationTitleRenderer.new({ invert_link_colour: true, bold_all_text: true }) + Redcarpet::Markdown.new(banner_renderer, no_intra_emphasis: true).render(title) end def render_for_summary(title) - @@plain_title_renderer ||= NotificationTitleRenderer.new({ invert_link_colour: false, bold_all_text: false }) - @@plain_title_markdown ||= Redcarpet::Markdown.new(@@plain_title_renderer, no_intra_emphasis: true) - @@plain_title_markdown.render(title) + plain_title_renderer ||= NotificationTitleRenderer.new({ invert_link_colour: false, bold_all_text: false }) + Redcarpet::Markdown.new(plain_title_renderer, no_intra_emphasis: true).render(title) end +end -private - - class NotificationTitleRenderer < Redcarpet::Render::HTML - def initialize(options = {}) - link_class = "govuk-link" - link_class += " govuk-link--inverse" if options[:invert_link_colour] - @bold = options[:bold_all_text] - base_options = { escape_html: true, safe_links_only: true, link_attributes: { class: link_class } } - super base_options - end +class NotificationTitleRenderer < Redcarpet::Render::HTML + def initialize(options = {}) + link_class = "govuk-link" + link_class += " govuk-link--inverse" if options[:invert_link_colour] + @bold = options[:bold_all_text] + base_options = { escape_html: true, safe_links_only: true, link_attributes: { class: link_class } } + super base_options + end - def paragraph(text) - return %(

#{text}

) if @bold + def paragraph(text) + return %(

#{text}

) if @bold - %(

#{text}

) - end + %(

#{text}

) end end