Skip to content

Commit

Permalink
Added Rake task rails:templates:copy to copy templates for customizat…
Browse files Browse the repository at this point in the history
…ion [#4574 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
jeroenvandijk authored and josevalim committed May 15, 2010
1 parent c77794a commit 80fc653
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions railties/lib/rails/tasks/framework.rake
Expand Up @@ -30,6 +30,28 @@ namespace :rails do
generator.apply template, :verbose => false
end

namespace :templates do
desc "Copy all the templates from rails to the application directory for customization. Already existing local copies will be overwritten"
task :copy do
generators_lib = File.expand_path("../../generators", __FILE__)
project_templates = "#{Rails.root}/lib/templates"

default_templates = { "erb" => %w{controller mailer scaffold},
"rails" => %w{controller helper metal scaffold_controller stylesheets} }

default_templates.each do |type, names|
local_template_type_dir = File.join(project_templates, type)
FileUtils.mkdir_p local_template_type_dir

names.each do |name|
dst_name = File.join(local_template_type_dir, name)
src_name = File.join(generators_lib, type, name, "templates")
FileUtils.cp_r src_name, dst_name
end
end
end
end

namespace :update do
def invoke_from_app_generator(method)
app_generator.invoke(method)
Expand Down

0 comments on commit 80fc653

Please sign in to comment.