aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-02-19 20:55:56 -0600
committerJoshua Peek <josh@joshpeek.com>2009-02-19 20:55:56 -0600
commitf8ea9f85d4f1e3e6f3b5d895bef6b013aa4b0690 (patch)
tree3dcac4ab4c1d170df4ecaa327513c81c742f1fda /actionpack/lib/action_view/template.rb
parent7c0e008973e594ebf53607362c1dfbe34b693600 (diff)
downloadrails-f8ea9f85d4f1e3e6f3b5d895bef6b013aa4b0690.tar.gz
rails-f8ea9f85d4f1e3e6f3b5d895bef6b013aa4b0690.tar.bz2
rails-f8ea9f85d4f1e3e6f3b5d895bef6b013aa4b0690.zip
Fix templates reloading in development when using custom view path [#2012 state:resolved]
Diffstat (limited to 'actionpack/lib/action_view/template.rb')
-rw-r--r--actionpack/lib/action_view/template.rb24
1 files changed, 10 insertions, 14 deletions
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index b8e2165ddf..ea838b9b02 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -6,12 +6,7 @@ module ActionView #:nodoc:
def initialize(path)
raise ArgumentError, "path already is a Path class" if path.is_a?(Path)
- @path = expand_path(path).freeze
- end
-
- def expand_path(path)
- # collapse any directory dots in path ('.' or '..')
- path.starts_with?('/') ? File.expand_path(path) : File.expand_path(path, '/').from(1)
+ @path = (path.ends_with?(File::SEPARATOR) ? path.to(-2) : path).freeze
end
def to_s
@@ -45,22 +40,23 @@ module ActionView #:nodoc:
# will never match +hello/index.html.erb+.
def [](path)
end
-
+
def load!
end
-
+
def self.new_and_loaded(path)
returning new(path) do |path|
path.load!
end
end
+
+ private
+ def relative_path_for_template_file(full_file_path)
+ full_file_path.split("#{@path}/").last
+ end
end
class EagerPath < Path
- def initialize(path)
- super
- end
-
def load!
return if @loaded
@@ -79,7 +75,7 @@ module ActionView #:nodoc:
load! unless @loaded
@paths[path]
end
-
+
private
def templates_in_path
(Dir.glob("#{@path}/**/*/**") | Dir.glob("#{@path}/**")).each do |file|
@@ -88,7 +84,7 @@ module ActionView #:nodoc:
end
def create_template(file)
- Template.new(file.split("#{self}/").last, self)
+ Template.new(relative_path_for_template_file(file), self)
end
end