aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/base.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-09-16 01:31:17 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-09-16 01:31:17 +0000
commit35ffc1afbe583809e7a45945f381cb3b97aac7e9 (patch)
tree3f15c8856bca65f214940a52c473fba811e80060 /actionpack/lib/action_controller/base.rb
parent2271c17da17511ea0800a60bc5017ba0b2368438 (diff)
downloadrails-35ffc1afbe583809e7a45945f381cb3b97aac7e9.tar.gz
rails-35ffc1afbe583809e7a45945f381cb3b97aac7e9.tar.bz2
rails-35ffc1afbe583809e7a45945f381cb3b97aac7e9.zip
Declare file extensions exempt from layouts. Closes #6219.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5126 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/base.rb')
-rwxr-xr-xactionpack/lib/action_controller/base.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index f42686c318..c971989582 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -315,6 +315,9 @@ module ActionController #:nodoc:
# Returns the name of the action this controller is processing.
attr_accessor :action_name
+ # Templates that are exempt from layouts
+ @@exempt_from_layout = Set.new([/\.rjs$/])
+
class << self
# Factory for the standard create, process loop where the controller is discarded after processing.
def process(request, response) #:nodoc:
@@ -395,6 +398,14 @@ module ActionController #:nodoc:
filtered_parameters
end
end
+
+ # Don't render layouts for templates with the given extensions.
+ def 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
end
public
@@ -1094,7 +1105,10 @@ module ActionController #:nodoc:
end
def template_exempt_from_layout?(template_name = default_template_name)
- template_name =~ /\.rjs$/ || (@template.pick_template_extension(template_name) == :rjs rescue false)
+ @@exempt_from_layout.any? { |ext| template_name =~ ext } or
+ @template.pick_template_extension(template_name) == :rjs
+ rescue
+ false
end
def assert_existence_of_template_file(template_name)