diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-07-03 13:01:39 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-07-03 13:01:39 +0100 |
commit | 2fe263bb328c20539f2970057f31e567ec4ab7c8 (patch) | |
tree | 63e85164fb09aca6beb78e1a5c52424fa49ed098 /actionpack/lib/action_view/base.rb | |
parent | bf5ac9965f12840d469ef2a4a16e8205dbbe5253 (diff) | |
parent | a4bdc00fec623f72592e663e6d7830eea0bc6ea4 (diff) | |
download | rails-2fe263bb328c20539f2970057f31e567ec4ab7c8.tar.gz rails-2fe263bb328c20539f2970057f31e567ec4ab7c8.tar.bz2 rails-2fe263bb328c20539f2970057f31e567ec4ab7c8.zip |
Merge commit 'mainstream/master'
Conflicts:
actionpack/lib/action_controller.rb
actionpack/lib/action_controller/base/base.rb
actionpack/lib/action_view/template/path.rb
activesupport/lib/active_support/json/encoders/hash.rb
Diffstat (limited to 'actionpack/lib/action_view/base.rb')
-rw-r--r-- | actionpack/lib/action_view/base.rb | 55 |
1 files changed, 17 insertions, 38 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 4ab568b44c..45184f58fb 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 @@ -229,38 +230,27 @@ 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 + @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] = "" } 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) + _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 ensure - self.template = last_template + self.template, self.formats = last_template, last_formats end def punctuate_body!(part) @@ -271,30 +261,19 @@ 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 + @assigns_added ||= _copy_ivars_from_controller 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 + true + 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 |