public this repo is viewable by everyone
Description: Most awesome pagination solution for Rails
Homepage: http://github.com/mislav/will_paginate/wikis
Clone URL: git://github.com/mislav/will_paginate.git
allow renderer to be a LinkRenderer instance or a class and make it easier 
to override rendering a link.
chriseppstein (author)
17 days ago
mislav (committer)
16 days ago
commit  85e6d44e738d0bf27cbbcc6cdd60d994a9c3e1c5
tree    a184af8d00df8ff2223a4bef4860f86aba29d33f
parent  cc485b2cc28cfdb306d8f04879d760043f03833c
...
92
93
94
95
96
 
 
 
 
 
 
 
 
 
 
 
97
98
99
...
169
170
171
 
 
 
172
173
174
...
258
259
260
261
 
262
263
 
264
265
266
 
 
 
 
 
 
 
 
 
267
268
269
...
92
93
94
 
 
95
96
97
98
99
100
101
102
103
104
105
106
107
108
...
178
179
180
181
182
183
184
185
186
...
270
271
272
 
273
274
 
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
0
@@ -92,8 +92,17 @@ module WillPaginate
0
       
0
       options = options.symbolize_keys.reverse_merge WillPaginate::ViewHelpers.pagination_options
0
       # create the renderer instance
0
- renderer_class = options[:renderer].to_s.constantize
0
- renderer = renderer_class.new collection, options, self
0
+ renderer = case options[:renderer]
0
+ when String, Class
0
+ renderer_class = options[:renderer].to_s.constantize
0
+ renderer_class.new collection, options, self
0
+ else
0
+ returning(options[:renderer]) do |r|
0
+ r.collection = collection
0
+ r.options = options
0
+ r.template = self
0
+ end
0
+ end
0
       # render HTML for pagination
0
       renderer.to_html
0
     end
0
@@ -169,6 +178,9 @@ module WillPaginate
0
   # This class does the heavy lifting of actually building the pagination
0
   # links. It is used by +will_paginate+ helper internally.
0
   class LinkRenderer
0
+
0
+ attr_accessor :collection, :options, :template
0
+
0
     # * +collection+ is a WillPaginate::Collection instance or any other object
0
     # that conforms to that API
0
     # * +options+ are forwarded from +will_paginate+ view helper
0
@@ -258,12 +270,21 @@ module WillPaginate
0
       classnames = Array[*span_class]
0
       
0
       if page and page != current_page
0
- @template.link_to text, url_for(page), :rel => rel_value(page), :class => classnames[1]
0
+ page_link page, text, :rel => rel_value(page), :class => classnames[1]
0
       else
0
- @template.content_tag :span, text, :class => classnames.join(' ')
0
+ page_span page, text, :class => classnames.join(' ')
0
       end
0
     end
0
 
0
+ def page_link(page, text, attributes = {})
0
+ @template.link_to text, url_for(page), attributes
0
+ end
0
+
0
+ def page_span(page, text, attributes = {})
0
+ @template.content_tag :span, text, attributes
0
+ end
0
+
0
+
0
     # Returns URL params for +page_link_or_span+, taking the current GET params
0
     # and <tt>:params</tt> option into account.
0
     def url_for(page)

Comments

    No one has commented yet.