Browse Source

Refactor render_for_page helper

pull/2630/head
Rachael Booth 2 years ago
parent
commit
72652c408d
  1. 10
      app/helpers/notifications_helper.rb
  2. 2
      app/views/notifications/show.html.erb

10
app/helpers/notifications_helper.rb

@ -27,11 +27,11 @@ module NotificationsHelper
render_normal_markdown(title) render_normal_markdown(title)
end end
def render_for_page(title, page_content) def render_for_page(notification)
content = page_content content_includes_own_title = /\A\s*#[^#]/.match?(notification.page_content)
unless /\A\s*#[^#]/.match?(page_content) return render_normal_markdown(notification.page_content) if content_includes_own_title
content = "# #{title}\n#{page_content}"
end content = "# #{notification.title}\n#{notification.page_content}"
render_normal_markdown(content) render_normal_markdown(content)
end end

2
app/views/notifications/show.html.erb

@ -5,7 +5,7 @@
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%== render_for_page(@notification.title, @notification.page_content) %> <%== render_for_page(@notification) %>
</div> </div>
</div> </div>
<br> <br>

Loading…
Cancel
Save