From e3e5ad4c5fed07eda993648f1998d9b0f5c78921 Mon Sep 17 00:00:00 2001 From: Herve Saint-Amand Date: Mon, 16 Jan 2017 22:50:01 +0000 Subject: [PATCH 1/1] Refactored the code to invoke the message body partial layout, as suggested in the PR --- app/helpers/notifier_helper.rb | 7 +++++++ ..._user_message_table.html.erb => _message_body.html.erb} | 2 +- app/views/notifier/changeset_comment_notification.html.erb | 4 ++-- app/views/notifier/diary_comment_notification.html.erb | 4 ++-- app/views/notifier/friend_notification.html.erb | 4 ++-- app/views/notifier/message_notification.html.erb | 4 ++-- app/views/notifier/note_comment_notification.html.erb | 4 ++-- 7 files changed, 18 insertions(+), 11 deletions(-) rename app/views/notifier/{_user_message_table.html.erb => _message_body.html.erb} (96%) diff --git a/app/helpers/notifier_helper.rb b/app/helpers/notifier_helper.rb index 62801ed82..0510ae0a8 100644 --- a/app/helpers/notifier_helper.rb +++ b/app/helpers/notifier_helper.rb @@ -11,4 +11,11 @@ module NotifierHelper :style => "text-decoration: none; color: #222; font-weight: bold" ) end + + def message_body(&block) + render( + partial: "message_body", + locals: { body: capture(&block) } + ) + end end diff --git a/app/views/notifier/_user_message_table.html.erb b/app/views/notifier/_message_body.html.erb similarity index 96% rename from app/views/notifier/_user_message_table.html.erb rename to app/views/notifier/_message_body.html.erb index 1b33e082b..29ecf9ea8 100644 --- a/app/views/notifier/_user_message_table.html.erb +++ b/app/views/notifier/_message_body.html.erb @@ -12,7 +12,7 @@ ) %> - <%= captured %> + <%= body %> diff --git a/app/views/notifier/changeset_comment_notification.html.erb b/app/views/notifier/changeset_comment_notification.html.erb index cb2748f4a..bbcd0614e 100644 --- a/app/views/notifier/changeset_comment_notification.html.erb +++ b/app/views/notifier/changeset_comment_notification.html.erb @@ -11,9 +11,9 @@ <% end %>

-<%= render "notifier/user_message_table", :captured => capture { %> +<%= message_body do %> <%= @comment.to_html %> -<% } %> +<% end %>

<%= raw t 'notifier.changeset_comment_notification.details', :url => content_tag("nobr", link_to(@changeset_url, @changeset_url)) %> diff --git a/app/views/notifier/diary_comment_notification.html.erb b/app/views/notifier/diary_comment_notification.html.erb index 4b7c63105..73bfe9a33 100644 --- a/app/views/notifier/diary_comment_notification.html.erb +++ b/app/views/notifier/diary_comment_notification.html.erb @@ -5,9 +5,9 @@ <%= raw t'notifier.diary_comment_notification.header', :from_user => link_to_user(@from_user), :subject => content_tag("em", @title) %>

-<%= render "notifier/user_message_table", :captured => capture { %> +<%= message_body do %> <%= @text.to_html %> -<% } %> +<% end %> <% content_for :footer do %>

<%= raw t'notifier.diary_comment_notification.footer', diff --git a/app/views/notifier/friend_notification.html.erb b/app/views/notifier/friend_notification.html.erb index 356aca0aa..cfea97195 100644 --- a/app/views/notifier/friend_notification.html.erb +++ b/app/views/notifier/friend_notification.html.erb @@ -1,9 +1,9 @@

<%= t 'notifier.friend_notification.had_added_you', :user => @friend.befriender.display_name %>

-<%= render "notifier/user_message_table", :captured => capture { %> +<%= message_body do %>

<%= raw t 'notifier.friend_notification.see_their_profile', :userurl => link_to(@viewurl, @viewurl) %>

<% unless @friend.befriendee.is_friends_with?(@friend.befriender) -%>

<%= raw t 'notifier.friend_notification.befriend_them', :befriendurl => link_to(@friendurl, @friendurl) %>

<% end -%> -<% } %> +<% end %> diff --git a/app/views/notifier/message_notification.html.erb b/app/views/notifier/message_notification.html.erb index d3871f030..97a352a49 100644 --- a/app/views/notifier/message_notification.html.erb +++ b/app/views/notifier/message_notification.html.erb @@ -8,9 +8,9 @@ %>

-<%= render "notifier/user_message_table", :captured => capture { %> +<%= message_body do %> <%= @text.to_html %> -<% } %> +<% end %> <% content_for :footer do %>

diff --git a/app/views/notifier/note_comment_notification.html.erb b/app/views/notifier/note_comment_notification.html.erb index 749298531..ecaff81dc 100644 --- a/app/views/notifier/note_comment_notification.html.erb +++ b/app/views/notifier/note_comment_notification.html.erb @@ -6,8 +6,8 @@

<%= raw t "notifier.note_comment_notification.#{@event}.commented_note", :commenter => link_to_user(@commenter), :place => @place %>

<% end %> -<%= render "notifier/user_message_table", :captured => capture { %> +<%= message_body do %> <%= @comment.to_html %> -<% } %> +<% end %>

<%= raw t 'notifier.note_comment_notification.details', :url => link_to(@noteurl, @noteurl) %>

-- 2.45.1