Skip to content

Commit

Permalink
Allow layouts with extension of .html.erb. Closes #8032 [Josh Knowles]
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6516 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
technoweenie committed Apr 12, 2007
1 parent d699084 commit f5b8fc0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN* *SVN*


* Allow layouts with extension of .html.erb. Closes #8032 [Josh Knowles]

* Change default respond_to templates for xml and rjs formats. [Rick] * Change default respond_to templates for xml and rjs formats. [Rick]


* Default xml template goes from #{action_name}.rxml => #{action_name}.xml.builder. * Default xml template goes from #{action_name}.rxml => #{action_name}.xml.builder.
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/layout.rb
Expand Up @@ -190,7 +190,7 @@ def layout_list #:nodoc:
def inherited_with_layout(child) def inherited_with_layout(child)
inherited_without_layout(child) inherited_without_layout(child)
layout_match = child.name.underscore.sub(/_controller$/, '').sub(/^controllers\//, '') layout_match = child.name.underscore.sub(/_controller$/, '').sub(/^controllers\//, '')
child.layout(layout_match) unless child.layout_list.grep(%r{layouts/#{layout_match}\.[a-z][0-9a-z]*$}).empty? child.layout(layout_match) unless child.layout_list.grep(%r{layouts/#{layout_match}(\.[a-z][0-9a-z]*)+$}).empty?
end end


def add_layout_conditions(conditions) def add_layout_conditions(conditions)
Expand Down
10 changes: 10 additions & 0 deletions actionpack/test/controller/layout_test.rb
Expand Up @@ -28,6 +28,9 @@ module ControllerNameSpace
class ControllerNameSpace::NestedController < LayoutTest class ControllerNameSpace::NestedController < LayoutTest
end end


class MultipleExtensions < LayoutTest
end

class MabView class MabView
def initialize(view) def initialize(view)
end end
Expand Down Expand Up @@ -72,6 +75,13 @@ def test_namespaced_controllers_auto_detect_layouts
assert_equal 'layouts/controller_name_space/nested', @controller.active_layout assert_equal 'layouts/controller_name_space/nested', @controller.active_layout
assert_equal 'controller_name_space/nested.rhtml hello.rhtml', @response.body assert_equal 'controller_name_space/nested.rhtml hello.rhtml', @response.body
end end

def test_namespaced_controllers_auto_detect_layouts
@controller = MultipleExtensions.new
get :hello
assert_equal 'layouts/multiple_extensions', @controller.active_layout
assert_equal 'multiple_extensions.html.erb hello.rhtml', @response.body.strip
end
end end


class ExemptFromLayoutTest < Test::Unit::TestCase class ExemptFromLayoutTest < Test::Unit::TestCase
Expand Down

0 comments on commit f5b8fc0

Please sign in to comment.