mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Use template engine as option since it's the one used by rails.
This commit is contained in:
parent
e81d428d53
commit
185541b9e4
1 changed files with 12 additions and 12 deletions
|
@ -4,7 +4,7 @@ class DeviseViewsGenerator < Rails::Generators::Base
|
|||
argument :scope, :required => false, :default => nil,
|
||||
:desc => "The scope to copy views to"
|
||||
|
||||
class_option :engine, :type => :string, :aliases => "-t", :default => "erb",
|
||||
class_option :template_engine, :type => :string, :aliases => "-t", :default => "erb",
|
||||
:desc => "Template engine for the views. Available options are 'erb' and 'haml'."
|
||||
|
||||
def self.source_root
|
||||
|
@ -12,7 +12,7 @@ class DeviseViewsGenerator < Rails::Generators::Base
|
|||
end
|
||||
|
||||
def copy_views
|
||||
case options[:engine]
|
||||
case options[:template_engine]
|
||||
when "erb"
|
||||
directory "devise", "app/views/devise/#{scope}"
|
||||
when "haml"
|
||||
|
@ -43,23 +43,23 @@ class DeviseViewsGenerator < Rails::Generators::Base
|
|||
def create_and_copy_haml_views
|
||||
require 'tmpdir'
|
||||
|
||||
devise_html_source_root = "#{DeviseViewsGenerator.source_root}/devise"
|
||||
devise_haml_source_root = "#{Dir.tmpdir}/devise-haml"
|
||||
html_root = "#{self.class.source_root}/devise"
|
||||
haml_root = "#{Dir.tmpdir}/devise-haml"
|
||||
|
||||
# reset the temp folder so that no deprecated files (if any) will get copied across
|
||||
FileUtils.remove_dir devise_haml_source_root, true
|
||||
# Reset the temp folder so that no deprecated files (if any) will get copied across
|
||||
FileUtils.rm_rf(haml_root, true)
|
||||
|
||||
Dir["#{devise_html_source_root}/**/*"].each do |path|
|
||||
relative_path = path.sub(devise_html_source_root, "")
|
||||
source_path = (devise_haml_source_root + relative_path).sub(/erb$/, "haml")
|
||||
Dir["#{html_root}/**/*"].each do |path|
|
||||
relative_path = path.sub(html_root, "")
|
||||
source_path = (haml_root + relative_path).sub(/erb$/, "haml")
|
||||
|
||||
if File.directory?(path)
|
||||
FileUtils.mkdir_p source_path
|
||||
FileUtils.mkdir_p(source_path)
|
||||
else
|
||||
`html2haml -r #{path} #{source_path}`
|
||||
end
|
||||
end
|
||||
|
||||
directory devise_haml_source_root, "app/views/devise/#{scope}"
|
||||
directory haml_root, "app/views/devise/#{scope}"
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue