Permalink
Browse files

Speed up template inheritance and remove template inheritance option

  • Loading branch information...
wycats committed Dec 27, 2010
1 parent 7c568fd commit e03e1fdbc85bc05536a2770817c31b08d4f6be51
Showing with 17 additions and 28 deletions.
  1. +17 −16 actionpack/lib/abstract_controller/rendering.rb
  2. +0 −12 actionpack/test/controller/new_base/render_test.rb
@@ -60,6 +60,20 @@ def view_context_class
end
end
end
+
+ def parent_prefixes
+ @parent_prefixes ||= begin
+ parent_controller = superclass
+ prefixes = []
+
+ until parent_controller.abstract?
+ prefixes << parent_controller.controller_path
+ parent_controller = parent_controller.superclass
+ end
+
+ prefixes
+ end
+ end
end
attr_writer :view_context_class
@@ -116,18 +130,10 @@ def _render_template(options) #:nodoc:
# The prefixes used in render "foo" shortcuts.
def _prefixes
- prefixes = [controller_path]
-
- if template_inheritance?
- parent_controller = self.class.superclass
-
- until parent_controller.abstract?
- prefixes << parent_controller.controller_path
- parent_controller = parent_controller.superclass
- end
+ @_prefixes ||= begin
+ parent_prefixes = self.class.parent_prefixes
+ parent_prefixes.dup.unshift(controller_path)
end
-
- prefixes
end
private
@@ -176,10 +182,5 @@ def _normalize_options(options)
def _process_options(options)
end
-
- def template_inheritance?
- # is there a better way to check for config option being set?
- config.template_inheritance.nil? ? true : config.template_inheritance
- end
end
end
@@ -53,10 +53,6 @@ class ChildRenderController < BlankRenderController
prepend_view_path ActionView::FixtureResolver.new("render/child_render/overriden_with_own_view_paths_prepended.html.erb" => "child content")
end
- class ChildRenderWithoutInheritanceController < BlankRenderController
- config.template_inheritance = false
- end
-
class RenderTest < Rack::TestCase
test "render with blank" do
with_routing do |set|
@@ -138,12 +134,4 @@ class TestViewInheritance < Rack::TestCase
assert_body "Hello world!"
end
end
-
- class TestNoViewInheritance < Rack::TestCase
- test "Template from parent controller does not get picked if config.action_controller.template_inheritance = false" do
- assert_raises(ActionView::MissingTemplate) do
- get "/render/child_render_without_inheritance/index", {}, "action_dispatch.show_exceptions" => false
- end
- end
- end
end

0 comments on commit e03e1fd

Please sign in to comment.