lib/generators/inky/install_generator.rb in inky-rb-1.3.7.1 vs lib/generators/inky/install_generator.rb in inky-rb-1.3.7.2

- old
+ new

@@ -4,16 +4,17 @@ module Generators 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}") + def preserve_original_mailer_layout + 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 end def create_mailer_stylesheet @@ -30,9 +31,16 @@ File.join('app', 'assets', 'stylesheets') end 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