diff options
author | José Valim <jose.valim@gmail.com> | 2010-02-06 17:32:06 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-02-06 17:32:06 +0100 |
commit | 6958eac1a00a4ab33e3facc70c80a07492288196 (patch) | |
tree | 06df21a64b2111690701b273e121620437afe155 /railties/lib | |
parent | 1d9d9d2d89a90a85f27a1909e3c435c070bc1b40 (diff) | |
download | rails-6958eac1a00a4ab33e3facc70c80a07492288196.tar.gz rails-6958eac1a00a4ab33e3facc70c80a07492288196.tar.bz2 rails-6958eac1a00a4ab33e3facc70c80a07492288196.zip |
Add config.generators.templates to provide alternative paths for template lookup.
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/configuration.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/engine/configuration.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/generators.rb | 5 | ||||
-rw-r--r-- | railties/lib/rails/generators/base.rb | 3 |
5 files changed, 13 insertions, 3 deletions
diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 7887a5d25f..50675d19b8 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -88,12 +88,13 @@ module Rails end class Generators #:nodoc: - attr_accessor :aliases, :options, :fallbacks, :colorize_logging + attr_accessor :aliases, :options, :templates, :fallbacks, :colorize_logging def initialize @aliases = Hash.new { |h,k| h[k] = {} } @options = Hash.new { |h,k| h[k] = {} } @fallbacks = {} + @templates = [] @colorize_logging = true end diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 33d62c8155..5983a9ee6b 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -102,6 +102,10 @@ module Rails app.metal_loader.paths.unshift(*paths.app.metals.to_a) end + initializer :add_generator_templates do |app| + config.generators.templates.unshift(*paths.lib.templates.to_a) + end + initializer :load_application_initializers do paths.config.initializers.to_a.sort.each do |initializer| load(initializer) diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb index 7d6de91430..93b882f874 100644 --- a/railties/lib/rails/engine/configuration.rb +++ b/railties/lib/rails/engine/configuration.rb @@ -21,6 +21,7 @@ module Rails paths.app.views "app/views" paths.lib "lib", :load_path => true paths.lib.tasks "lib/tasks", :glob => "**/*.rake" + paths.lib.templates "lib/templates" paths.config "config" paths.config.initializers "config/initializers", :glob => "**/*.rb" paths.config.locales "config/locales", :glob => "*.{rb,yml}" diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 5d95f2fa52..5779357226 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -66,6 +66,11 @@ module Rails aliases.deep_merge! config.aliases options.deep_merge! config.options fallbacks.merge! config.fallbacks + templates_path.concat config.templates + end + + def self.templates_path + @templates_path ||= [] end def self.aliases #:nodoc: diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index dfa0d573c9..c801e2fec3 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -213,8 +213,7 @@ module Rails if base.name && base.name !~ /Base$/ Rails::Generators.subclasses << base - if defined?(Rails.root) && Rails.root - path = File.expand_path(File.join(Rails.root, 'lib', 'templates')) + Rails::Generators.templates_path.each do |path| if base.name.include?('::') base.source_paths << File.join(path, base.base_name, base.generator_name) else |