diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-04-20 18:31:22 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-04-20 18:31:40 -0700 |
commit | 685a53a360d0d8fc4a9f3b49f900621c940a71f2 (patch) | |
tree | fa6b38f75a873a21c3e380f1acbab3d019293363 /actionpack/lib/action_view/paths.rb | |
parent | db05c73fb6e2294c576ef9889c70940891682c32 (diff) | |
parent | 164a94d0bc8c9124ab820506e5ad79496395c026 (diff) | |
download | rails-685a53a360d0d8fc4a9f3b49f900621c940a71f2.tar.gz rails-685a53a360d0d8fc4a9f3b49f900621c940a71f2.tar.bz2 rails-685a53a360d0d8fc4a9f3b49f900621c940a71f2.zip |
Merge branch 'master' into cherry
Conflicts:
activesupport/CHANGELOG
activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
activesupport/lib/active_support/core_ext/hash/conversions.rb
activesupport/lib/active_support/core_ext/module/attribute_accessors.rb
activesupport/lib/active_support/core_ext/string/multibyte.rb
activesupport/lib/active_support/core_ext/time/calculations.rb
activesupport/lib/active_support/deprecation.rb
Diffstat (limited to 'actionpack/lib/action_view/paths.rb')
-rw-r--r-- | actionpack/lib/action_view/paths.rb | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/actionpack/lib/action_view/paths.rb b/actionpack/lib/action_view/paths.rb index 8cc3fe291c..1d0279889c 100644 --- a/actionpack/lib/action_view/paths.rb +++ b/actionpack/lib/action_view/paths.rb @@ -2,16 +2,13 @@ module ActionView #:nodoc: class PathSet < Array #:nodoc: def self.type_cast(obj) if obj.is_a?(String) - if Base.cache_template_loading? - Template::EagerPath.new(obj.to_s) - else - ReloadableTemplate::ReloadablePath.new(obj.to_s) - end + cache = !Object.const_defined?(:Rails) || Rails.configuration.cache_classes + Template::FileSystemPath.new(obj, :cache => cache) else obj end end - + def initialize(*args) super(*args).map! { |obj| self.class.type_cast(obj) } end @@ -35,9 +32,29 @@ module ActionView #:nodoc: def unshift(*objs) super(*objs.map { |obj| self.class.type_cast(obj) }) end + + def find_by_parts(path, extension = nil, prefix = nil, partial = false) + template_path = path.sub(/^\//, '') + + each do |load_path| + if template = load_path.find_by_parts(template_path, extension, prefix, partial) + return template + end + end + + Template.new(path, self) + rescue ActionView::MissingTemplate => e + extension ||= [] + raise ActionView::MissingTemplate.new(self, "#{prefix}/#{path}.{#{extension.join(",")}}") + end - def load! - each(&:load!) + def find_by_parts?(path, extension = nil, prefix = nil, partial = false) + template_path = path.sub(/^\//, '') + + each do |load_path| + return true if template = load_path.find_by_parts(template_path, extension, prefix, partial) + end + false end def find_template(original_template_path, format = nil, html_fallback = true) @@ -45,13 +62,7 @@ module ActionView #:nodoc: template_path = original_template_path.sub(/^\//, '') each do |load_path| - if format && (template = load_path["#{template_path}.#{I18n.locale}.#{format}"]) - return template - elsif format && (template = load_path["#{template_path}.#{format}"]) - return template - elsif template = load_path["#{template_path}.#{I18n.locale}"] - return template - elsif template = load_path[template_path] + if template = load_path.find_by_parts(template_path, format) return template # Try to find html version if the format is javascript elsif format == :js && html_fallback && template = load_path["#{template_path}.#{I18n.locale}.html"] |