Permalink
Browse files

Added support for multiple type of template generation

  • Loading branch information...
ashrafuzzaman committed Jun 16, 2012
1 parent 741a7b6 commit ad1a5600d8356c3f2ff5428cd3f28cdc3a1efdf9
View
@@ -29,5 +29,5 @@ Install my templates
===========================
I preffer to use twitter bootstrap. So you can install twitter bootstrap supported templates by,
```ruby
rails g template:install
rails g template:install twitter
```
@@ -1,8 +1,5 @@
Description:
Explain the generator
rails g template:install twitter
Example:
rails generate install Thing
This will create:
what/will/it/create
Copies the templates in to the lib directory. So that scaffold will use these templates to generate.
@@ -2,30 +2,30 @@
module Template
module Generators
class InstallGenerator < ::Rails::Generators::Base
class InstallGenerator < Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)
def copy_view_templates
available_view_templates.each do |file|
file_with_ext = "erb/scaffold/#{file}.html.erb"
copy_file file_with_ext, "lib/templates/#{file_with_ext}"
copy_file "erb/scaffold/#{name}/#{file}.html.erb",
"lib/templates/erb/scaffold/#{file}.html.erb"
end
end
def copy_controller_template
file_with_ext = "rails/scaffold_controller/controller.rb"
copy_file file_with_ext, "lib/templates/#{file_with_ext}"
copy_file file_with_ext, "lib/templates/#{file_with_ext}"
end
def copy_helper_template
file_with_ext = "rails/helper/helper.rb"
copy_file file_with_ext, "lib/templates/#{file_with_ext}"
copy_file file_with_ext, "lib/templates/#{file_with_ext}"
end
private
def available_view_templates
%w(show new edit _form index)
end
%w(show new edit _form index)
end
end
end
end

0 comments on commit ad1a560

Please sign in to comment.