def will_paginate(collection = nil, options = {})
      options, collection = collection, nil if collection.is_a? Hash
      unless collection or !controller
        collection_name = "@#{controller.controller_name}"
        collection = instance_variable_get(collection_name)
        raise ArgumentError, "The #{collection_name} variable appears to be empty. Did you " +
          "forget to pass the collection object for will_paginate?" unless collection
      end
      # early exit if there is nothing to render
      return nil unless WillPaginate::ViewHelpers.total_pages_for_collection(collection) > 1
      
      options = options.symbolize_keys.reverse_merge WillPaginate::ViewHelpers.pagination_options
      
      # get the renderer instance
      renderer = case options[:renderer]
      when String
        options[:renderer].to_s.constantize.new
      when Class
        options[:renderer].new
      else
        options[:renderer]
      end
      # render HTML for pagination
      renderer.prepare collection, options, self
      renderer.to_html
    end
def will_paginate(collection = nil, options = {})
      options, collection = collection, nil if collection.is_a? Hash
      unless collection or !controller
        collection_name = "@#{controller.controller_name}"
        collection = instance_variable_get(collection_name)
        raise ArgumentError, "The #{collection_name} variable appears to be empty. Did you " +
          "forget to pass the collection object for will_paginate?" unless collection
      end
      # early exit if there is nothing to render
      return nil unless WillPaginate::ViewHelpers.total_pages_for_collection(collection) > 1
      
      options = options.symbolize_keys.reverse_merge WillPaginate::ViewHelpers.pagination_options
      
      # get the renderer instance
      renderer = case options[:renderer]
      when String
        options[:renderer].to_s.constantize.new
      when Class
        options[:renderer].new
      else
        options[:renderer]
      end
      # render HTML for pagination
      renderer.prepare collection, options, self
      renderer.to_html
    end
Renders Digg/Flickr-style pagination for a WillPaginate::Collection
 object. Nil is returned if there is only one page in total; no point in
 rendering the pagination in that case...

 ==== Options
 * <tt>:class</tt> -- CSS class name for the generated DIV (default: "pagination")
 * <tt>:prev_label</tt> -- default: "« Previous"
 * <tt>:next_label</tt> -- default: "Next »"
 * <tt>:inner_window</tt> -- how many links are shown around the current page (default: 4)
 * <tt>:outer_window</tt> -- how many links are around the first and the last page (default: 1)
 * <tt>:separator</tt> -- string separator for page HTML elements (default: single space)
 * <tt>:param_name</tt> -- parameter name for page number in URLs (default: <tt>:page</tt>)
 * <tt>:params</tt> -- additional parameters when generating pagination links
   (eg. <tt>:controller => "foo", :action => nil</tt>)
 * <tt>:renderer</tt> -- class name, class or instance of a link renderer (default:
   <tt>WillPaginate::LinkRenderer</tt>)
 * <tt>:page_links</tt> -- when false, only previous/next links are rendered (default: true)
 * <tt>:container</tt> -- toggles rendering of the DIV container for pagination links, set to
   false only when you are rendering your own pagination markup (default: true)
 * <tt>:id</tt> -- HTML ID for the container (default: nil). Pass +true+ to have the ID
   automatically generated from the class name of objects in collection: for example, paginating
   ArticleComment models would yield an ID of "article_comments_pagination".

 All options beside listed ones are passed as HTML attributes to the container
 element for pagination links (the DIV). For example:

   <%= will_paginate @posts, :id => 'wp_posts' %>

 ... will result in:

   <div class="pagination" id="wp_posts"> ... </div>

 ==== Using the helper without arguments
 If the helper is called without passing in the collection object, it will
 try to read from the instance variable inferred by the controller name.
 For example, calling +will_paginate+ while the current controller is
 PostsController will result in trying to read from the <tt>@posts</tt>
 variable. Example:

   <%= will_paginate :id => true %>

 ... will result in <tt>@post</tt> collection getting paginated:

   <div class="pagination" id="posts_pagination"> ... </div>