From 72652c408dd8d03e369534d09d04bc58de5c83e1 Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Tue, 10 Sep 2024 10:37:16 +0100 Subject: [PATCH] Refactor render_for_page helper --- app/helpers/notifications_helper.rb | 10 +++++----- app/views/notifications/show.html.erb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index f59d836ab..318918134 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -27,11 +27,11 @@ module NotificationsHelper render_normal_markdown(title) end - def render_for_page(title, page_content) - content = page_content - unless /\A\s*#[^#]/.match?(page_content) - content = "# #{title}\n#{page_content}" - end + def render_for_page(notification) + content_includes_own_title = /\A\s*#[^#]/.match?(notification.page_content) + return render_normal_markdown(notification.page_content) if content_includes_own_title + + content = "# #{notification.title}\n#{notification.page_content}" render_normal_markdown(content) end diff --git a/app/views/notifications/show.html.erb b/app/views/notifications/show.html.erb index eda582d90..a3933db55 100644 --- a/app/views/notifications/show.html.erb +++ b/app/views/notifications/show.html.erb @@ -5,7 +5,7 @@
- <%== render_for_page(@notification.title, @notification.page_content) %> + <%== render_for_page(@notification) %>