Class: HamlRails::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/haml_rails/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#change_application_rbObject



29
30
31
32
33
# File 'lib/generators/haml_rails/install_generator.rb', line 29

def change_application_rb
  inject_into_file "config/application.rb", :after => "class Application < Rails::Application\n" do
    "    config.generators do |g|\n      g.template_engine :haml\n    end\n"
  end
end

#copy_base_fileObject



26
27
28
# File 'lib/generators/haml_rails/install_generator.rb', line 26

def copy_base_file
  copy_file File.expand_path('../templates/base.rb', __FILE__), "#{@haml_dir}/base.rb"
end

#copy_controller_templateObject



7
8
9
10
11
# File 'lib/generators/haml_rails/install_generator.rb', line 7

def copy_controller_template        
  @haml_dir = "lib/generators/haml"
  copy_file File.expand_path('../templates/controller/controller_generator.rb', __FILE__), "#{@haml_dir}/controller/controller_generator.rb"
  copy_file File.expand_path('../templates/controller/templates/view.html.haml', __FILE__), "#{@haml_dir}/controller/templates/view.html.haml"
end

#copy_mailer_templateObject



12
13
14
15
# File 'lib/generators/haml_rails/install_generator.rb', line 12

def copy_mailer_template      
  copy_file File.expand_path('../templates/mailer/mailer_generator.rb', __FILE__), "#{@haml_dir}/mailer/mailer_generator.rb"
  copy_file File.expand_path('../templates/mailer/templates/view.text.haml', __FILE__), "#{@haml_dir}/mailer/templates/view.text.haml"
end

#copy_scaffold_templateObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/haml_rails/install_generator.rb', line 16

def copy_scaffold_template
  copy_file File.expand_path('../templates/scaffold/scaffold_generator.rb', __FILE__), "#{@haml_dir}/scaffold/scaffold_generator.rb"
  copy_file File.expand_path('../templates/scaffold/templates/_form.html.haml', __FILE__), "#{@haml_dir}/scaffold/templates/_form.html.haml"
  copy_file File.expand_path('../templates/scaffold/templates/edit.html.haml', __FILE__), "#{@haml_dir}/scaffold/templates/edit.html.haml"
  copy_file File.expand_path('../templates/scaffold/templates/index.html.haml', __FILE__), "#{@haml_dir}/scaffold/templates/index.html.haml"
  copy_file File.expand_path('../templates/scaffold/templates/layout.html.haml', __FILE__), "#{@haml_dir}/scaffold/templates/layout.html.haml"
  copy_file File.expand_path('../templates/scaffold/templates/new.html.haml', __FILE__), "#{@haml_dir}/scaffold/templates/new.html.haml"
  copy_file File.expand_path('../templates/scaffold/templates/show.html.haml', __FILE__), "#{@haml_dir}/scaffold/templates/show.html.haml"
  copy_file File.expand_path('../templates/scaffold/templates/_form.html.haml', __FILE__), "lib/templates/haml/scaffold/templates/_form.html.haml"
end