Browse Source

Adjust notifications helper

pull/2613/head
Rachael Booth 2 years ago
parent
commit
f4223d2f97
  1. 36
      app/helpers/notifications_helper.rb

36
app/helpers/notifications_helper.rb

@ -16,32 +16,28 @@ module NotificationsHelper
end end
def render_for_banner(title) def render_for_banner(title)
@@banner_renderer ||= NotificationTitleRenderer.new({ invert_link_colour: true, bold_all_text: true }) banner_renderer ||= NotificationTitleRenderer.new({ invert_link_colour: true, bold_all_text: true })
@@banner_markdown ||= Redcarpet::Markdown.new(@@banner_renderer, no_intra_emphasis: true) Redcarpet::Markdown.new(banner_renderer, no_intra_emphasis: true).render(title)
@@banner_markdown.render(title)
end end
def render_for_summary(title) def render_for_summary(title)
@@plain_title_renderer ||= NotificationTitleRenderer.new({ invert_link_colour: false, bold_all_text: false }) 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) Redcarpet::Markdown.new(plain_title_renderer, no_intra_emphasis: true).render(title)
@@plain_title_markdown.render(title)
end end
end
private class NotificationTitleRenderer < Redcarpet::Render::HTML
def initialize(options = {})
class NotificationTitleRenderer < Redcarpet::Render::HTML link_class = "govuk-link"
def initialize(options = {}) link_class += " govuk-link--inverse" if options[:invert_link_colour]
link_class = "govuk-link" @bold = options[:bold_all_text]
link_class += " govuk-link--inverse" if options[:invert_link_colour] base_options = { escape_html: true, safe_links_only: true, link_attributes: { class: link_class } }
@bold = options[:bold_all_text] super base_options
base_options = { escape_html: true, safe_links_only: true, link_attributes: { class: link_class } } end
super base_options
end
def paragraph(text) def paragraph(text)
return %(<p class="govuk-!-font-weight-bold">#{text}</p>) if @bold return %(<p class="govuk-!-font-weight-bold">#{text}</p>) if @bold
%(<p>#{text}</p>) %(<p>#{text}</p>)
end
end end
end end

Loading…
Cancel
Save