From 4fad953f90f82e860a69d67745887b40d5b15475 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 17 Jun 2009 12:00:23 -0700 Subject: Fixing pending tests and fixed some formats / partial rendering semantics --- actionpack/lib/action_view/base.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'actionpack/lib/action_view/base.rb') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 4ab568b44c..2d8f51300a 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -258,9 +258,11 @@ module ActionView #:nodoc: def with_template(current_template) last_template, self.template = template, current_template + old_formats, self.formats = formats, [current_template.mime_type.to_sym] + Mime::SET.symbols yield ensure self.template = last_template + self.formats = old_formats end def punctuate_body!(part) -- cgit v1.2.3 From 55ee0ba7f5b6b5d2023eb5dcc030946ed589fe53 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 17 Jun 2009 16:23:11 -0700 Subject: Cleaning up if defined?(ActionController::Http) blocks from the pre new base era. --- actionpack/lib/action_view/base.rb | 52 ++++++++++---------------------------- 1 file changed, 14 insertions(+), 38 deletions(-) (limited to 'actionpack/lib/action_view/base.rb') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 2d8f51300a..1ca6f839a8 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -230,39 +230,24 @@ module ActionView #:nodoc: def initialize(view_paths = [], assigns_for_first_render = {}, controller = nil, formats = nil)#:nodoc: @formats = formats || [:html] @assigns = assigns_for_first_render - @assigns_added = nil @controller = controller @helpers = ProxyModule.new(self) self.view_paths = view_paths - - @_first_render = nil - @_current_render = nil end + attr_internal :template attr_reader :view_paths def view_paths=(paths) @view_paths = self.class.process_view_paths(paths) end - # Access the current template being rendered. - # Returns a ActionView::Template object. - def template - @_current_render - end - - def template=(template) #:nodoc: - @_first_render ||= template - @_current_render = template - end - def with_template(current_template) last_template, self.template = template, current_template - old_formats, self.formats = formats, [current_template.mime_type.to_sym] + Mime::SET.symbols + last_formats, self.formats = formats, [current_template.mime_type.to_sym] + Mime::SET.symbols yield ensure - self.template = last_template - self.formats = old_formats + self.template, self.formats = last_template, last_formats end def punctuate_body!(part) @@ -273,30 +258,21 @@ module ActionView #:nodoc: # Evaluates the local assigns and controller ivars, pushes them to the view. def _evaluate_assigns_and_ivars #:nodoc: - unless @assigns_added - @assigns.each { |key, value| instance_variable_set("@#{key}", value) } - _copy_ivars_from_controller - @assigns_added = true - end + return if @assigns_added + @assigns.each { |key, value| instance_variable_set("@#{key}", value) } + _copy_ivars_from_controller + @assigns_added = true end - private + private - def _copy_ivars_from_controller #:nodoc: - if @controller - variables = @controller.instance_variable_names - variables -= @controller.protected_instance_variables if @controller.respond_to?(:protected_instance_variables) - variables.each { |name| instance_variable_set(name, @controller.instance_variable_get(name)) } - end + def _copy_ivars_from_controller #:nodoc: + if @controller + variables = @controller.instance_variable_names + variables -= @controller.protected_instance_variables if @controller.respond_to?(:protected_instance_variables) + variables.each { |name| instance_variable_set(name, @controller.instance_variable_get(name)) } end + end - def _set_controller_content_type(content_type) #:nodoc: - # TODO: Remove this method when new base is switched - unless defined?(ActionController::Http) - if controller.respond_to?(:response) - controller.response.content_type ||= content_type - end - end - end end end -- cgit v1.2.3 From a9ad763c86e110c280be0b7a763496f9e1204de0 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 17 Jun 2009 18:08:45 -0700 Subject: Drive the final stake through @content_for_*'s heart! --- actionpack/lib/action_view/base.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/base.rb') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 1ca6f839a8..b994c7b141 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -170,12 +170,13 @@ module ActionView #:nodoc: attr_accessor :base_path, :assigns, :template_extension, :formats attr_accessor :controller + attr_internal :captures attr_accessor :output_buffer class << self delegate :erb_trim_mode=, :to => 'ActionView::TemplateHandlers::ERB' - delegate :logger, :to => 'ActionController::Base' + delegate :logger, :to => 'ActionController::Base', :allow_nil => true end @@debug_rjs = false @@ -232,6 +233,7 @@ module ActionView #:nodoc: @assigns = assigns_for_first_render @controller = controller @helpers = ProxyModule.new(self) + @_content_for = Hash.new {|h,k| h[k] = "" } self.view_paths = view_paths end -- cgit v1.2.3 From 9f7eaea201b2f408d9effbf82f2731957e284adf Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Thu, 18 Jun 2009 12:08:50 -0700 Subject: Minor ActionView cleanup --- actionpack/lib/action_view/base.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'actionpack/lib/action_view/base.rb') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index b994c7b141..45184f58fb 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -230,7 +230,7 @@ module ActionView #:nodoc: def initialize(view_paths = [], assigns_for_first_render = {}, controller = nil, formats = nil)#:nodoc: @formats = formats || [:html] - @assigns = assigns_for_first_render + @assigns = assigns_for_first_render.each { |key, value| instance_variable_set("@#{key}", value) } @controller = controller @helpers = ProxyModule.new(self) @_content_for = Hash.new {|h,k| h[k] = "" } @@ -245,6 +245,7 @@ module ActionView #:nodoc: end def with_template(current_template) + _evaluate_assigns_and_ivars last_template, self.template = template, current_template last_formats, self.formats = formats, [current_template.mime_type.to_sym] + Mime::SET.symbols yield @@ -260,10 +261,7 @@ module ActionView #:nodoc: # Evaluates the local assigns and controller ivars, pushes them to the view. def _evaluate_assigns_and_ivars #:nodoc: - return if @assigns_added - @assigns.each { |key, value| instance_variable_set("@#{key}", value) } - _copy_ivars_from_controller - @assigns_added = true + @assigns_added ||= _copy_ivars_from_controller end private @@ -274,6 +272,7 @@ module ActionView #:nodoc: variables -= @controller.protected_instance_variables if @controller.respond_to?(:protected_instance_variables) variables.each { |name| instance_variable_set(name, @controller.instance_variable_get(name)) } end + true end end -- cgit v1.2.3