aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/paths.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-04-22 15:26:03 +0100
committerPratik Naik <pratiknaik@gmail.com>2009-04-22 15:26:03 +0100
commit5f3f100ce2d689480da85abc88e5e940cf90189e (patch)
tree15c1a05a5308a9eea56d7f0889ac46d9cac5b57c /actionpack/lib/action_view/paths.rb
parentd758d996d1b66e2a65640f79f01ce2ac674d7ed5 (diff)
parentca49299434bc764b667cd86846d892e91a150ef3 (diff)
downloadrails-5f3f100ce2d689480da85abc88e5e940cf90189e.tar.gz
rails-5f3f100ce2d689480da85abc88e5e940cf90189e.tar.bz2
rails-5f3f100ce2d689480da85abc88e5e940cf90189e.zip
Merge branch 'master' into active_model
Conflicts: activeresource/lib/active_resource/validations.rb
Diffstat (limited to 'actionpack/lib/action_view/paths.rb')
-rw-r--r--actionpack/lib/action_view/paths.rb41
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"]