From 38cfaa828502b2f5d137a6a2952c68ae5efc15b1 Mon Sep 17 00:00:00 2001 From: Andy Jeffries Date: Mon, 17 Nov 2014 10:44:04 +0000 Subject: Creates an ApplicationMailer and layout by default, including html and body tags to reduce spam score --- .../rails/generators/erb/mailer/mailer_generator.rb | 20 ++++++++++++++++++++ .../generators/erb/mailer/templates/layout.html.erb | 5 +++++ .../generators/erb/mailer/templates/layout.text.erb | 1 + 3 files changed, 26 insertions(+) create mode 100644 railties/lib/rails/generators/erb/mailer/templates/layout.html.erb create mode 100644 railties/lib/rails/generators/erb/mailer/templates/layout.text.erb (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb index 66b17bd10e..b047973241 100644 --- a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb +++ b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb @@ -3,6 +3,26 @@ require 'rails/generators/erb/controller/controller_generator' module Erb # :nodoc: module Generators # :nodoc: class MailerGenerator < ControllerGenerator # :nodoc: + def copy_view_files + view_base_path = File.join("app/views", class_path, file_name) + empty_directory view_base_path + + layout_base_path = File.join("app/views/layouts") + + actions.each do |action| + @action = action + + formats.each do |format| + @view_path = File.join(view_base_path, filename_with_extensions(action, format)) + template filename_with_extensions(:view, format), @view_path + + @layout_path = File.join(layout_base_path, filename_with_extensions("mailer", format)) + template filename_with_extensions(:layout, format), @layout_path + end + end + + end + protected def formats diff --git a/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb b/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb new file mode 100644 index 0000000000..93110e74ad --- /dev/null +++ b/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb @@ -0,0 +1,5 @@ + + + <%%= yield %> + + diff --git a/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb b/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb new file mode 100644 index 0000000000..6363733e6e --- /dev/null +++ b/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb @@ -0,0 +1 @@ +<%%= yield %> -- cgit v1.2.3