diff options
author | Eileen M. Uchitelle <eileencodes@gmail.com> | 2016-06-12 09:18:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-12 09:18:46 -0400 |
commit | 39fa2c53299e0edf81b361fb784ce783081085ed (patch) | |
tree | b94065c7f44cab66d8fd2c991b1b991900f87348 /railties/lib | |
parent | 8f8a07d7eb01adeb399874d3046ee9b4664075e1 (diff) | |
parent | f0f4cb2f64566020b6edd48e0a81fd744ffc2e4c (diff) | |
download | rails-39fa2c53299e0edf81b361fb784ce783081085ed.tar.gz rails-39fa2c53299e0edf81b361fb784ce783081085ed.tar.bz2 rails-39fa2c53299e0edf81b361fb784ce783081085ed.zip |
Merge pull request #25004 from y-yagi/generate_mailer_layout_files_if_it_does_not_already_exist
generate mailer layout files if it does not already exist
Diffstat (limited to 'railties/lib')
3 files changed, 21 insertions, 0 deletions
diff --git a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb index 7f00943d80..97f3657070 100644 --- a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb +++ b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb @@ -9,6 +9,13 @@ module Erb # :nodoc: view_base_path = File.join("app/views", class_path, file_name + '_mailer') empty_directory view_base_path + if self.behavior == :invoke + formats.each do |format| + layout_path = File.join('app/views/layouts', class_path, filename_with_extensions('mailer', format)) + template filename_with_extensions(:layout, format), layout_path + end + end + actions.each do |action| @action = action diff --git a/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt b/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt new file mode 100644 index 0000000000..55f3675d49 --- /dev/null +++ b/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <style> + /* Email styles need to be inline */ + </style> + </head> + + <body> + <%%= yield %> + </body> +</html> diff --git a/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb.tt b/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb.tt new file mode 100644 index 0000000000..6363733e6e --- /dev/null +++ b/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb.tt @@ -0,0 +1 @@ +<%%= yield %> |