diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-11-19 14:00:16 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-11-19 14:00:16 +0100 |
commit | 130fe74d17404e5c06353526c7b20beb4019cb69 (patch) | |
tree | ad15653d1f1ab20151d4bdc934106e8f857d08f7 /actionpack/lib/action_view/base.rb | |
parent | 0c9f677e7861ef2aae36d91811d72794e4709f58 (diff) | |
download | rails-130fe74d17404e5c06353526c7b20beb4019cb69.tar.gz rails-130fe74d17404e5c06353526c7b20beb4019cb69.tar.bz2 rails-130fe74d17404e5c06353526c7b20beb4019cb69.zip |
Changed the default of ActionView#render to assume partials instead of files when not given an options hash [DHH]
Diffstat (limited to 'actionpack/lib/action_view/base.rb')
-rw-r--r-- | actionpack/lib/action_view/base.rb | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 511858dd9b..0d3752d875 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -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 |