class TailwindViews::Generators::DeviseGenerator

Generator to run to add devise templates to the application

Public Instance Methods

install() click to toggle source
# File lib/generators/tailwind_views/devise_generator.rb, line 23
def install
  template "#{file_template_location('confirmations/new')}.tt", "app/views/devise/confirmations/new.html.#{options[:template_engine]}", force: true
  directory "#{options[:template_engine]}/mailer", 'app/views/devise/mailer', force: true

  %i[edit new].map do |file|
    template "#{file_template_location("passwords/#{file}")}.tt", "app/views/devise/passwords/#{file}.html.#{options[:template_engine]}", force: true
    template "#{file_template_location("registrations/#{file}")}.tt", "app/views/devise/registrations/#{file}.html.#{options[:template_engine]}", force: true
  end
  template "#{file_template_location('sessions/new')}.tt", "app/views/devise/sessions/new.html.#{options[:template_engine]}", force: true
  template "#{file_template_location('unlocks/new')}.tt", "app/views/devise/unlocks/new.html.#{options[:template_engine]}", force: true
  directory "#{options[:template_engine]}/shared", 'app/views/devise/shared', force: true
end

Private Instance Methods

file_template_location(file_location = '') click to toggle source
# File lib/generators/tailwind_views/devise_generator.rb, line 38
def file_template_location(file_location = '')
  return '' if file_location.blank?

  # Depending if simpleform is to be used, it will return a path similar to one of the following:
  # => slim/unlocks/new.html.slim || simple_form/slim/unlocks/new.html.slim
  "#{simple_path}#{options[:template_engine]}/#{file_location}.html.#{options[:template_engine]}"
end
simple_path() click to toggle source

If simpleform is going ot be used with the forms return a simple_form path

# File lib/generators/tailwind_views/devise_generator.rb, line 47
def simple_path
  options[:simpleform] ? 'simple_form/' : ''
end