From d2222e657770430ff10c1470a59d4a803073a1b9 Mon Sep 17 00:00:00 2001 From: thedarkone Date: Fri, 20 Mar 2009 23:02:16 +0100 Subject: [PATCH] Simplify handling of absolute path templates. [#2276 state:resolved] --- actionpack/lib/action_view/paths.rb | 2 +- actionpack/lib/action_view/template.rb | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/actionpack/lib/action_view/paths.rb b/actionpack/lib/action_view/paths.rb index 8cc3fe2..a0a2f96 100644 --- a/actionpack/lib/action_view/paths.rb +++ b/actionpack/lib/action_view/paths.rb @@ -61,7 +61,7 @@ module ActionView #:nodoc: 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 diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index c339c8a..4497c4a 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -107,9 +107,8 @@ module ActionView #:nodoc: 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 @@ module ActionView #:nodoc: @@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 -- 1.6.0.1