aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/paths.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view/paths.rb')
-rw-r--r--actionpack/lib/action_view/paths.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/paths.rb b/actionpack/lib/action_view/paths.rb
index 6c6d2ff979..b6bb9942ee 100644
--- a/actionpack/lib/action_view/paths.rb
+++ b/actionpack/lib/action_view/paths.rb
@@ -2,7 +2,11 @@ module ActionView #:nodoc:
class PathSet < Array #:nodoc:
def self.type_cast(obj)
if obj.is_a?(String)
- Template::EagerPath.new(obj)
+ if !Object.const_defined?(:Rails) || Rails.configuration.cache_classes
+ Template::EagerPath.new(obj)
+ else
+ Template::Path.new(obj)
+ end
else
obj
end
@@ -56,7 +60,7 @@ module ActionView #:nodoc:
false
end
- def find_template(original_template_path, format = nil)
+ def find_template(original_template_path, format = nil, html_fallback = true)
return original_template_path if original_template_path.respond_to?(:render)
template_path = original_template_path.sub(/^\//, '')
@@ -64,12 +68,16 @@ module ActionView #:nodoc:
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 && template = load_path["#{template_path}.html"]
+ elsif format == :js && html_fallback && template = load_path["#{template_path}.#{I18n.locale}.html"]
+ return template
+ elsif format == :js && html_fallback && template = load_path["#{template_path}.html"]
return template
end
end
- Template.new(original_template_path, self)
+ return Template.new(original_template_path, original_template_path.to_s =~ /\A\// ? "" : ".") if File.file?(original_template_path)
+
+ raise MissingTemplate.new(self, original_template_path, format)
end
end
end