diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-01 12:37:57 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-01 13:40:13 +0200 |
commit | 367bdc53611fe1da9cedda3220a83d3f39409cff (patch) | |
tree | f9f2fe13521d436a61d7068b7fc1b7d3e27f363e /actionpack/lib/action_view/renderer/partial_renderer.rb | |
parent | 33cc001f9158463389a9c9c321de0dbdccb1df8d (diff) | |
download | rails-367bdc53611fe1da9cedda3220a83d3f39409cff.tar.gz rails-367bdc53611fe1da9cedda3220a83d3f39409cff.tar.bz2 rails-367bdc53611fe1da9cedda3220a83d3f39409cff.zip |
Remove view dependency from AV::Renderer.
Diffstat (limited to 'actionpack/lib/action_view/renderer/partial_renderer.rb')
-rw-r--r-- | actionpack/lib/action_view/renderer/partial_renderer.rb | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb index 0eeead2e5d..70327b16c4 100644 --- a/actionpack/lib/action_view/renderer/partial_renderer.rb +++ b/actionpack/lib/action_view/renderer/partial_renderer.rb @@ -217,45 +217,14 @@ 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, *) + def initialize(*) super - @controller = @view.controller @partial_names = PARTIAL_NAMES[@controller.class.name] end - def setup(options, block) - partial = options[:partial] - - @options = options - @locals = options[:locals] || {} - @block = block - - if String === partial - @object = options[:object] - @path = partial - @collection = collection - else - @object = partial - - if @collection = collection_from_object || collection - paths = @collection_data = @collection.map { |o| partial_path(o) } - @path = paths.uniq.size == 1 ? paths.first : nil - else - @path = partial_path - end - end + def render(context, options, block) + setup(context, options, block) - if @path - @variable, @variable_counter = retrieve_variable(@path) - else - paths.map! { |path| retrieve_variable(path).unshift(path) } - end - - self - end - - def render wrap_formats(@path) do identifier = ((@template = find_partial) ? @template.identifier : @path) @@ -303,6 +272,38 @@ module ActionView private + def setup(context, options, block) + @view = context + partial = options[:partial] + + @options = options + @locals = options[:locals] || {} + @block = block + + if String === partial + @object = options[:object] + @path = partial + @collection = collection + else + @object = partial + + if @collection = collection_from_object || collection + paths = @collection_data = @collection.map { |o| partial_path(o) } + @path = paths.uniq.size == 1 ? paths.first : nil + else + @path = partial_path + end + end + + if @path + @variable, @variable_counter = retrieve_variable(@path) + else + paths.map! { |path| retrieve_variable(path).unshift(path) } + end + + self + end + def controller_prefixes @controller_prefixes ||= @controller && @controller._prefixes end |