From c7564d74e8a9b451f9fc78566ab0c734671f9612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 7 Mar 2010 19:41:58 +0100 Subject: Added template lookup responsible to hold all information used in template lookup. --- actionpack/lib/action_view/render/partials.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_view/render/partials.rb') diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index 8b6dce0c1c..74513935a7 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -309,7 +309,7 @@ module ActionView prefix = controller.controller_path unless path.include?(?/) end - @view.find(path, {:formats => @view.formats}, prefix, true) + @view.find(path, prefix, true) end def partial_path(object = @object) @@ -329,7 +329,7 @@ module ActionView details = options[:_details] - # Is this needed + # TODO This should happen automatically as well self.formats = details[:formats] if details renderer = PartialRenderer.new(self, options, nil) text = renderer.render -- cgit v1.2.3 From ffd8d753f171a33cb0f8dadaff7fc5ba12b8f6b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 8 Mar 2010 02:04:18 +0100 Subject: Move layout lookup to views. --- actionpack/lib/action_view/render/partials.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/render/partials.rb') diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index 74513935a7..52cb188508 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -330,7 +330,7 @@ module ActionView details = options[:_details] # TODO This should happen automatically as well - self.formats = details[:formats] if details + self.formats = details[:formats] if details[:formats] renderer = PartialRenderer.new(self, options, nil) text = renderer.render options[:_template] = renderer.template -- cgit v1.2.3 From 4bae77a89baf0fee15c6b2cfd3987f7344b56a1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 8 Mar 2010 02:58:16 +0100 Subject: More cleanup on the layouts side. --- actionpack/lib/action_view/render/partials.rb | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'actionpack/lib/action_view/render/partials.rb') diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index 52cb188508..eecc88a1e0 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -182,9 +182,6 @@ module ActionView @view = view_context @partial_names = PARTIAL_NAMES[@view.controller.class] - key = Thread.current[:format_locale_key] - @templates = TEMPLATES[key] if key - setup(options, block) end @@ -296,15 +293,9 @@ module ActionView end end - def find_template(path = @path) - unless @templates - path && _find_template(path) - else - path && @templates[path] ||= _find_template(path) - end - end + def find_template(path=@path) + return path unless path.is_a?(String) - def _find_template(path) if controller = @view.controller prefix = controller.controller_path unless path.include?(?/) end -- cgit v1.2.3 From ea68fe59c670dd5580f3aa34fdfa0eb89eb717d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 8 Mar 2010 14:46:57 +0100 Subject: More refactoring on the views side of rendering. --- actionpack/lib/action_view/render/partials.rb | 33 ++++++--------------------- 1 file changed, 7 insertions(+), 26 deletions(-) (limited to 'actionpack/lib/action_view/render/partials.rb') diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index eecc88a1e0..950c9d2cd8 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -174,9 +174,6 @@ module ActionView class PartialRenderer PARTIAL_NAMES = Hash.new {|h,k| h[k] = {} } - TEMPLATES = Hash.new {|h,k| h[k] = {} } - - attr_reader :template def initialize(view_context, options, block) @view = view_context @@ -225,6 +222,7 @@ module ActionView if !@block && (layout = @options[:layout]) content = @view._render_layout(find_template(layout), @locals){ content } end + content end end @@ -241,9 +239,9 @@ module ActionView end def collection_with_template(template = @template) - segments, locals, as = [], @locals, @options[:as] || template.variable_name + segments, locals, as, template = [], @locals, @options[:as] || @template.variable_name, @template - counter_name = template.counter_name + counter_name = template.counter_name locals[counter_name] = -1 @collection.each do |object| @@ -253,7 +251,6 @@ module ActionView segments << template.render(@view, locals) end - @template = template segments end @@ -274,7 +271,7 @@ module ActionView end def render_partial(object = @object) - locals, view = @locals, @view + locals, view, template = @locals, @view, @template object ||= locals[template.variable_name] locals[@options[:as] || template.variable_name] = object @@ -285,6 +282,7 @@ module ActionView end private + def collection if @object.respond_to?(:to_ary) @object @@ -295,11 +293,7 @@ module ActionView def find_template(path=@path) return path unless path.is_a?(String) - - if controller = @view.controller - prefix = controller.controller_path unless path.include?(?/) - end - + prefix = @view.controller_path unless path.include?(?/) @view.find(path, prefix, true) end @@ -315,21 +309,8 @@ module ActionView end end - def render_partial(options) - _evaluate_assigns_and_ivars - - details = options[:_details] - - # TODO This should happen automatically as well - self.formats = details[:formats] if details[:formats] - renderer = PartialRenderer.new(self, options, nil) - text = renderer.render - options[:_template] = renderer.template - text - end - def _render_partial(options, &block) #:nodoc: - if defined? @renderer + if defined?(@renderer) @renderer.setup(options, block) else @renderer = PartialRenderer.new(self, options, block) -- cgit v1.2.3 From 44ebab96da0ab47cc45c64a6efdd2cbb80f9d042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 8 Mar 2010 15:19:03 +0100 Subject: Rename Template::Lookup to LookupContext. --- actionpack/lib/action_view/render/partials.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/render/partials.rb') diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index 950c9d2cd8..0fe2d560f7 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -294,7 +294,7 @@ module ActionView def find_template(path=@path) return path unless path.is_a?(String) prefix = @view.controller_path unless path.include?(?/) - @view.find(path, prefix, true) + @view.find_template(path, prefix, true) end def partial_path(object = @object) -- cgit v1.2.3 From 8f082ff4217175f52234f2223658619a9c923afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 8 Mar 2010 23:13:24 +0100 Subject: Clean LookupContext API. --- actionpack/lib/action_view/render/partials.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/render/partials.rb') diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index 0fe2d560f7..950c9d2cd8 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -294,7 +294,7 @@ module ActionView def find_template(path=@path) return path unless path.is_a?(String) prefix = @view.controller_path unless path.include?(?/) - @view.find_template(path, prefix, true) + @view.find(path, prefix, true) end def partial_path(object = @object) -- cgit v1.2.3