diff options
author | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-12-03 19:30:35 +0100 |
---|---|---|
committer | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-12-03 19:30:35 +0100 |
commit | ccb96f2297e8783165cba764e9b5d51e1a15ff87 (patch) | |
tree | 3229e6fdddc42054615514d843c555e341003033 /actionpack/lib/action_view/base.rb | |
parent | fb2325e35855d62abd2c76ce03feaa3ca7992e4f (diff) | |
parent | 761a633a9c0a45d76ef3ed10da97e3696c3ded79 (diff) | |
download | rails-ccb96f2297e8783165cba764e9b5d51e1a15ff87.tar.gz rails-ccb96f2297e8783165cba764e9b5d51e1a15ff87.tar.bz2 rails-ccb96f2297e8783165cba764e9b5d51e1a15ff87.zip |
Merge commit 'origin/master' into savepoints
Conflicts:
activerecord/lib/active_record/fixtures.rb
activerecord/test/cases/defaults_test.rb
Diffstat (limited to 'actionpack/lib/action_view/base.rb')
-rw-r--r-- | actionpack/lib/action_view/base.rb | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 945246a39a..da1f283deb 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -157,7 +157,7 @@ module ActionView #:nodoc: # # See the ActionView::Helpers::PrototypeHelper::GeneratorMethods documentation for more details. class Base - include ERB::Util + include Helpers, Partials, ::ERB::Util extend ActiveSupport::Memoizable attr_accessor :base_path, :assigns, :template_extension @@ -234,16 +234,21 @@ module ActionView #:nodoc: @view_paths = self.class.process_view_paths(paths) end - # Renders the template present at <tt>template_path</tt> (relative to the view_paths array). - # The hash in <tt>local_assigns</tt> is made available as local variables. + # Returns the result of a render that's dictated by the options hash. The primary options are: + # + # * <tt>:partial</tt> - See ActionView::Partials. + # * <tt>:update</tt> - Calls update_page with the block given. + # * <tt>:file</tt> - Renders an explicit template file (this used to be the old default), add :locals to pass in those. + # * <tt>:inline</tt> - Renders an inline template similar to how it's done in the controller. + # * <tt>:text</tt> - Renders the text passed in out. + # + # If no options hash is passed or :update specified, the default is to render a partial and use the second parameter + # as the locals hash. def render(options = {}, local_assigns = {}, &block) #:nodoc: local_assigns ||= {} - if options.is_a?(String) - render(:file => options, :locals => local_assigns) - elsif options == :update - update_page(&block) - elsif options.is_a?(Hash) + case options + when Hash options = options.reverse_merge(:locals => {}) if options[:layout] _render_with_layout(options, local_assigns, &block) @@ -256,6 +261,10 @@ module ActionView #:nodoc: elsif options[:text] options[:text] end + when :update + update_page(&block) + else + render_partial(:partial => options, :locals => local_assigns) end end @@ -313,11 +322,10 @@ module ActionView #:nodoc: end # OPTIMIZE: Checks to lookup template in view path - if template = self.view_paths["#{template_file_name}.#{template_format}"] - template - elsif template = self.view_paths[template_file_name] + if template = self.view_paths.find_template(template_file_name, template_format) template - elsif @_render_stack.first && template = self.view_paths["#{template_file_name}.#{@_render_stack.first.format_and_extension}"] + elsif (first_render = @_render_stack.first) && first_render.respond_to?(:format_and_extension) && + (template = self.view_paths["#{template_file_name}.#{first_render.format_and_extension}"]) template elsif template_format == :js && template = self.view_paths["#{template_file_name}.html"] @template_format = :html |