diff options
author | Jeroen van Dijk + Rodrigo Urubatan <jeroen@jeevidee.nl> | 2010-05-14 23:54:13 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-05-15 14:59:29 +0200 |
commit | 80fc6536bda191731e3963f1539c84a7b0c4e764 (patch) | |
tree | 26cc0a837e4162b195d77f4c6007ef439b1c5a76 /railties/lib | |
parent | c77794a924938360bf4e61c9a13cdbe5b58fdf62 (diff) | |
download | rails-80fc6536bda191731e3963f1539c84a7b0c4e764.tar.gz rails-80fc6536bda191731e3963f1539c84a7b0c4e764.tar.bz2 rails-80fc6536bda191731e3963f1539c84a7b0c4e764.zip |
Added Rake task rails:templates:copy to copy templates for customization [#4574 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/tasks/framework.rake | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/railties/lib/rails/tasks/framework.rake b/railties/lib/rails/tasks/framework.rake index 738f7f5301..063a393bfc 100644 --- a/railties/lib/rails/tasks/framework.rake +++ b/railties/lib/rails/tasks/framework.rake @@ -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) |