class SimpleDiscussion::BootstrapLinkRenderer
This code serves two purposes
-
It patches will_paginate to work with scoped and mounted Rails engines by adding in the url_builder option
-
It adds Bootstrap 4 styling to will_paginate
Public Instance Methods
url(page)
click to toggle source
This method adds the `url_builder` option so we can pass in the mounted Rails engine's scope for will_paginate
# File lib/simple_discussion/will_paginate.rb, line 12 def url(page) @base_url_params ||= begin url_params = merge_get_params(default_url_params) merge_optional_params(url_params) end url_params = @base_url_params.dup add_current_page_param(url_params, page) # Add optional url_builder support (@options[:url_builder] || @template).url_for(url_params) end
Protected Instance Methods
gap()
click to toggle source
# File lib/simple_discussion/will_paginate.rb, line 41 def gap tag :li, link("…".html_safe, "#", class: "page-link"), class: "page-item disabled" end
html_container(html)
click to toggle source
# File lib/simple_discussion/will_paginate.rb, line 27 def html_container(html) tag :nav, tag(:ul, html, class: ul_class) end
page_number(page)
click to toggle source
# File lib/simple_discussion/will_paginate.rb, line 31 def page_number(page) item_class = if page == current_page "active page-item" else "page-item" end tag :li, link(page, page, rel: rel_value(page), class: "page-link"), class: item_class end
previous_or_next_page(page, text, classname)
click to toggle source
# File lib/simple_discussion/will_paginate.rb, line 45 def previous_or_next_page(page, text, classname) tag :li, link(text, page || "#", class: "page-link"), class: [(classname[0..3] if @options[:page_links]), (classname if @options[:page_links]), ("disabled" unless page), "page-item"].join(" ") end
ul_class()
click to toggle source
# File lib/simple_discussion/will_paginate.rb, line 49 def ul_class ["pagination", container_attributes[:class]].compact.join(" ") end