diff options
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/base.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_view/renderer/partial_renderer.rb | 14 | ||||
-rw-r--r-- | actionpack/lib/action_view/renderer/renderer.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_view/rendering.rb | 17 |
4 files changed, 18 insertions, 20 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 0866e808e6..37cd4d9ddc 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -202,17 +202,13 @@ module ActionView #:nodoc: lookup_context : ActionView::LookupContext.new(lookup_context) @_lookup_context.formats = formats if formats - @_renderer = ActionView::Renderer.new(@_lookup_context, self) + @view_renderer = ActionView::Renderer.new(@_lookup_context, self) end def controller_path @controller_path ||= controller && controller.controller_path end - def controller_prefixes - @controller_prefixes ||= controller && controller._prefixes - end - ActiveSupport.run_load_hooks(:action_view, self) end end diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb index 83efc95f39..0eeead2e5d 100644 --- a/actionpack/lib/action_view/renderer/partial_renderer.rb +++ b/actionpack/lib/action_view/renderer/partial_renderer.rb @@ -217,9 +217,11 @@ module ActionView class PartialRenderer < AbstractRenderer #:nodoc: PARTIAL_NAMES = Hash.new {|h,k| h[k] = {} } + # TODO Controller should not come from the view def initialize(view, *) super - @partial_names = PARTIAL_NAMES[@view.controller.class.name] + @controller = @view.controller + @partial_names = PARTIAL_NAMES[@controller.class.name] end def setup(options, block) @@ -292,7 +294,7 @@ module ActionView locals[as] = object content = @template.render(view, locals) do |*name| - view._block_layout_for(*name, &block) + view._layout_for(*name, &block) end content = layout.render(view, locals){ content } if layout @@ -301,6 +303,10 @@ module ActionView private + def controller_prefixes + @controller_prefixes ||= @controller && @controller._prefixes + end + def collection if @options.key?(:collection) collection = @options[:collection] @@ -324,7 +330,7 @@ module ActionView end def find_template(path=@path, locals=@locals.keys) - prefixes = path.include?(?/) ? [] : @view.controller_prefixes + prefixes = path.include?(?/) ? [] : controller_prefixes @lookup_context.find_template(path, prefixes, true, locals) end @@ -365,7 +371,7 @@ module ActionView object = object.to_model if object.respond_to?(:to_model) object.class.model_name.partial_path.dup.tap do |partial| - path = @view.controller_prefixes.first + path = controller_prefixes.first partial.insert(0, "#{File.dirname(path)}/") if partial.include?(?/) && path.include?(?/) end end diff --git a/actionpack/lib/action_view/renderer/renderer.rb b/actionpack/lib/action_view/renderer/renderer.rb index f0ee103d80..7b95c2dd92 100644 --- a/actionpack/lib/action_view/renderer/renderer.rb +++ b/actionpack/lib/action_view/renderer/renderer.rb @@ -6,6 +6,7 @@ module ActionView attr_accessor :lookup_context # TODO: render_context should not be an initialization parameter + # TODO: controller should be received on initialization def initialize(lookup_context, render_context) @render_context = render_context @lookup_context = lookup_context diff --git a/actionpack/lib/action_view/rendering.rb b/actionpack/lib/action_view/rendering.rb index 017a27976c..9850965456 100644 --- a/actionpack/lib/action_view/rendering.rb +++ b/actionpack/lib/action_view/rendering.rb @@ -4,7 +4,7 @@ module ActionView # = Action View Rendering module Rendering # This is temporary until we remove the renderer dependency from AV. - delegate :render, :render_body, :to => :@_renderer + delegate :render, :render_body, :to => :@view_renderer # Returns the contents that are yielded to a layout, given a name or a block. # @@ -52,20 +52,15 @@ module ActionView # Hello David # </html> # - def _layout_for(*args) - name = args.first - name = :layout unless name.is_a?(Symbol) - @_view_flow.get(name).html_safe - end - - # Handle layout for calls from partials that supports blocks. - def _block_layout_for(*args, &block) + def _layout_for(*args, &block) name = args.first - if !name.is_a?(Symbol) && block + if name.is_a?(Symbol) + @_view_flow.get(name).html_safe + elsif block capture(*args, &block) else - _layout_for(*args) + @_view_flow.get(:layout).html_safe end end end |