Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify handling of absolute path templates. [#2276 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information...
commit e3b166aab37ddc2fbab030b146eb61713b91bf55 1 parent 4c2f09f
@thedarkone thedarkone authored josh committed
View
2  actionpack/lib/action_view/paths.rb
@@ -61,7 +61,7 @@ def find_template(original_template_path, format = nil, html_fallback = true)
end
end
- return Template.new(original_template_path, original_template_path.to_s =~ /\A\// ? "" : ".") if File.file?(original_template_path)
+ return Template.new(original_template_path) if File.file?(original_template_path)
raise MissingTemplate.new(self, original_template_path, format)
end
View
11 actionpack/lib/action_view/template.rb
@@ -107,9 +107,8 @@ def self.exempt_from_layout(*extensions)
attr_accessor :locale, :name, :format, :extension
delegate :to_s, :to => :path
- def initialize(template_path, load_path)
- @template_path = template_path.dup
- @load_path, @filename = load_path, File.join(load_path, template_path)
+ def initialize(template_path, load_path = nil)
+ @template_path, @load_path = template_path.dup, load_path
@base_path, @name, @locale, @format, @extension = split(template_path)
@base_path.to_s.gsub!(/\/$/, '') # Push to split method
@@ -180,6 +179,12 @@ def exempt_from_layout?
@@exempt_from_layout.any? { |exempted| path =~ exempted }
end
+ def filename
+ # no load_path means this is an "absolute pathed" template
+ load_path ? File.join(load_path, template_path) : template_path
+ end
+ memoize :filename
+
def source
File.read(filename)
end
Please sign in to comment.
Something went wrong with that request. Please try again.