From d20ebab761ef46f6c1a3e72a3c3d5f795b0cdd61 Mon Sep 17 00:00:00 2001 From: Jeroen van Dijk Date: Fri, 14 May 2010 23:54:13 +0200 Subject: [PATCH] Added Rake task rails:templates:copy to copy templates for customization --- railties/lib/rails/tasks/framework.rake | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/railties/lib/rails/tasks/framework.rake b/railties/lib/rails/tasks/framework.rake index 738f7f5..d690f8c 100644 --- a/railties/lib/rails/tasks/framework.rake +++ b/railties/lib/rails/tasks/framework.rake @@ -29,6 +29,29 @@ namespace :rails do generator = Rails::Generators::AppGenerator.new [ Rails.root ], {}, :destination_root => Rails.root 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) -- 1.6.0.2