aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-12-21 17:23:53 -0600
committerJoshua Peek <josh@joshpeek.com>2008-12-21 17:24:16 -0600
commit858a420ce18719c720b80508b336e37ce37a20bf (patch)
tree15c4178a13faa37476da412b738dfcc9e6398b04 /actionpack/lib/action_view/template.rb
parentf5b7f0911bc507673afe6a045176e6e3c7305d74 (diff)
downloadrails-858a420ce18719c720b80508b336e37ce37a20bf.tar.gz
rails-858a420ce18719c720b80508b336e37ce37a20bf.tar.bz2
rails-858a420ce18719c720b80508b336e37ce37a20bf.zip
Ensure the template format is always passed to the template finder. Now we can cleanup some nasty stuff.
Diffstat (limited to 'actionpack/lib/action_view/template.rb')
-rw-r--r--actionpack/lib/action_view/template.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index 93748638c3..5b384d0e4d 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -4,6 +4,17 @@ module ActionView #:nodoc:
extend ActiveSupport::Memoizable
include Renderable
+ # Templates that are exempt from layouts
+ @@exempt_from_layout = Set.new([/\.rjs$/])
+
+ # Don't render layouts for templates with the given extensions.
+ def self.exempt_from_layout(*extensions)
+ regexps = extensions.collect do |extension|
+ extension.is_a?(Regexp) ? extension : /\.#{Regexp.escape(extension.to_s)}$/
+ end
+ @@exempt_from_layout.merge(regexps)
+ end
+
attr_accessor :filename, :load_path, :base_path, :name, :format, :extension
delegate :to_s, :to => :path
@@ -17,6 +28,18 @@ module ActionView #:nodoc:
extend RenderablePartial if @name =~ /^_/
end
+ def accessible_paths
+ paths = []
+ paths << path
+ paths << path_without_extension
+ if multipart?
+ formats = format.split(".")
+ paths << "#{path_without_format_and_extension}.#{formats.first}"
+ paths << "#{path_without_format_and_extension}.#{formats.second}"
+ end
+ paths
+ end
+
def format_and_extension
(extensions = [format, extension].compact.join(".")).blank? ? nil : extensions
end
@@ -57,6 +80,10 @@ module ActionView #:nodoc:
end
memoize :relative_path
+ def exempt_from_layout?
+ @@exempt_from_layout.any? { |exempted| path =~ exempted }
+ end
+
def mtime
File.mtime(filename)
end
@@ -94,6 +121,7 @@ module ActionView #:nodoc:
def load!
@loaded = true
+ compile({})
freeze
end