From 2c44dd8b85534f4196f668cfd543df026a1bbfb7 Mon Sep 17 00:00:00 2001 From: Zoran Date: Fri, 28 Oct 2016 10:39:39 -0700 Subject: [PATCH 1/5] use literal tag delimiters for erb template --- lib/generators/inky/templates/mailer_layout.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generators/inky/templates/mailer_layout.html.erb b/lib/generators/inky/templates/mailer_layout.html.erb index 374751e..43d8b6f 100644 --- a/lib/generators/inky/templates/mailer_layout.html.erb +++ b/lib/generators/inky/templates/mailer_layout.html.erb @@ -4,7 +4,7 @@ - <%= stylesheet_link_tag "foundation_emails" %> + <%%= stylesheet_link_tag "foundation_emails" %> @@ -12,7 +12,7 @@
- <%= yield %> + <%%= yield %>
From d102d5daf9de690b32b759a8a01f40d04fc1f94e Mon Sep 17 00:00:00 2001 From: Zoran Date: Fri, 28 Oct 2016 12:10:23 -0700 Subject: [PATCH 2/5] rework install generator to take boolean options for templating system; update README --- README.md | 12 ++++++++++-- lib/generators/inky/install_generator.rb | 21 +++++++++++++++------ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ad1dc39..bcb899b 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,16 @@ Run the following command to set up the required styles and mailer layout: rails g inky:install ``` -(You can specify the generated mailer layout filename like so: `rails g inky:install some_name` and also your prefered -markup language like: `rails g inky:install mailer_layout slim`) +You can specify the layout name and templating language with the following options: + +``` +Usage: + rails generate inky:install [layout_name] [options] + +Options: + [--haml], [--no-haml] # Generate layout in Haml + [--slim], [--no-slim] # Generate layout in Slim +``` Rename your email templates to use the `.inky` file extension. Note that you'll still be able to use your default template engine within the `.inky` templates: diff --git a/lib/generators/inky/install_generator.rb b/lib/generators/inky/install_generator.rb index b7f212e..7f1b3e6 100644 --- a/lib/generators/inky/install_generator.rb +++ b/lib/generators/inky/install_generator.rb @@ -6,14 +6,16 @@ class InstallGenerator < ::Rails::Generators::Base desc 'Install Foundation for Emails' source_root File.join(File.dirname(__FILE__), 'templates') argument :layout_name, type: :string, default: 'mailer', banner: 'layout_name' - argument :extension, type: :string, default: 'erb', banner: 'extension' - def preserve_original_mailer_layout - return unless layout_name == 'mailer' + class_option :haml, desc: "Generate layout in Haml", type: :boolean + class_option :slim, desc: "Generate layout in Slim", type: :boolean - original_mailer = File.join(layouts_base_dir, "mailer.html.#{extension}") - rename_filename = File.join(layouts_base_dir, "old_mailer_#{Time.now.to_i}.html.erb") - File.rename(original_mailer, rename_filename) if File.exist? original_mailer + def preserve_original_mailer_layout + if layout_name == 'mailer' && extension == 'erb' + original_mailer = File.join(layouts_base_dir, "mailer.html.erb") + rename_filename = File.join(layouts_base_dir, "old_mailer_#{Time.now.to_i}.html.erb") + File.rename(original_mailer, rename_filename) if File.exist? original_mailer + end end def create_mailer_stylesheet @@ -33,6 +35,13 @@ def stylesheets_base_dir def layouts_base_dir File.join('app', 'views', 'layouts') end + + def extension + %w(haml slim).each do |ext| + return ext if options.send(ext) + end + 'erb' + end end end end From b81eba77145a71498c62c8d8af6d44b47a347344 Mon Sep 17 00:00:00 2001 From: Zoran Date: Fri, 28 Oct 2016 12:16:14 -0700 Subject: [PATCH 3/5] version bump --- lib/inky/rails/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/inky/rails/version.rb b/lib/inky/rails/version.rb index 223199c..88f2d61 100644 --- a/lib/inky/rails/version.rb +++ b/lib/inky/rails/version.rb @@ -1,6 +1,6 @@ module Inky module Rails - VERSION = "1.3.7.1".freeze + VERSION = "1.3.7.2".freeze end NODE_VERSION, GEM_VERSION = Rails::VERSION.rpartition('.').map(&:freeze) end From 37b90c4a80ab36c999c6a3b726f087b5f0c210b0 Mon Sep 17 00:00:00 2001 From: Zoran Date: Fri, 28 Oct 2016 15:06:44 -0700 Subject: [PATCH 4/5] switch to guard clause --- lib/generators/inky/install_generator.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/generators/inky/install_generator.rb b/lib/generators/inky/install_generator.rb index 7f1b3e6..51bba56 100644 --- a/lib/generators/inky/install_generator.rb +++ b/lib/generators/inky/install_generator.rb @@ -11,11 +11,10 @@ class InstallGenerator < ::Rails::Generators::Base class_option :slim, desc: "Generate layout in Slim", type: :boolean def preserve_original_mailer_layout - if layout_name == 'mailer' && extension == 'erb' - original_mailer = File.join(layouts_base_dir, "mailer.html.erb") - rename_filename = File.join(layouts_base_dir, "old_mailer_#{Time.now.to_i}.html.erb") - File.rename(original_mailer, rename_filename) if File.exist? original_mailer - end + return if layout_name == 'mailer' && extension == 'erb' + original_mailer = File.join(layouts_base_dir, "mailer.html.erb") + rename_filename = File.join(layouts_base_dir, "old_mailer_#{Time.now.to_i}.html.erb") + File.rename(original_mailer, rename_filename) if File.exist? original_mailer end def create_mailer_stylesheet From 70e786c07bd0f71104e630db1109bdfb9ffa2a95 Mon Sep 17 00:00:00 2001 From: Zoran Date: Fri, 28 Oct 2016 15:08:48 -0700 Subject: [PATCH 5/5] typo fix --- lib/generators/inky/install_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/inky/install_generator.rb b/lib/generators/inky/install_generator.rb index 51bba56..f7ce28a 100644 --- a/lib/generators/inky/install_generator.rb +++ b/lib/generators/inky/install_generator.rb @@ -11,7 +11,7 @@ class InstallGenerator < ::Rails::Generators::Base class_option :slim, desc: "Generate layout in Slim", type: :boolean def preserve_original_mailer_layout - return if layout_name == 'mailer' && extension == 'erb' + return unless layout_name == 'mailer' && extension == 'erb' original_mailer = File.join(layouts_base_dir, "mailer.html.erb") rename_filename = File.join(layouts_base_dir, "old_mailer_#{Time.now.to_i}.html.erb") File.rename(original_mailer, rename_filename) if File.exist? original_mailer