Method: PaginationHelper::Paginator#basic_html
- Defined in:
- app/helpers/pagination_helper.rb
#basic_html(view, window_size = 2, link_to_current_page = false, params = {}) ⇒ Object
Creates a basic HTML link bar for the given view. The first and last pages of the paginator are always shown, along with window_size pages around the current page. By default, the current page is displayed, but not linked; to change this behavior, pass true to the link_to_current_page argument. Specify additional link_to parameters with params.
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'app/helpers/pagination_helper.rb', line 335 def basic_html(view, window_size=2, link_to_current_page=false, params={}) window_pages = current.window(window_size).pages return if window_pages.length <= 1 unless link_to_current_page html = '' unless window_pages[0].first? html << view.link_to(first.number, first.to_link(params)) html << ' ... ' if window_pages[0].number - first.number > 1 html << ' ' end window_pages.each do |page| if current == page and not link_to_current_page html << page.number.to_s else html << view.link_to(page.number, page.to_link(params)) end html << ' ' end unless window_pages.last.last? html << ' ... ' if last.number - window_pages[-1].number > 1 html << view.link_to(last.number, last.to_link(params)) end html end |