aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template.rb
diff options
context:
space:
mode:
authorthedarkone <thedarkone2@gmail.com>2009-03-24 10:44:54 -0500
committerJoshua Peek <josh@joshpeek.com>2009-03-24 10:54:17 -0500
commite3b166aab37ddc2fbab030b146eb61713b91bf55 (patch)
tree7cb5c94d64fe5ef4c2a3b55e278b9a637b6b874d /actionpack/lib/action_view/template.rb
parent4c2f09f23a05823b076cdfb8ac39934e0678798a (diff)
downloadrails-e3b166aab37ddc2fbab030b146eb61713b91bf55.tar.gz
rails-e3b166aab37ddc2fbab030b146eb61713b91bf55.tar.bz2
rails-e3b166aab37ddc2fbab030b146eb61713b91bf55.zip
Simplify handling of absolute path templates. [#2276 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'actionpack/lib/action_view/template.rb')
-rw-r--r--actionpack/lib/action_view/template.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index c339c8a554..4497c4ac32 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