module MaterializePagination::MaterializeRenderer

MaterializeCSS UI Framework WillPaginate LinkRenderer

Public Instance Methods

gap() click to toggle source

@return [String] rendered gap between pagination links

# File lib/materialize_pagination/materialize_renderer.rb, line 19
def gap
  tag :li, link('…'.html_safe, '#'), :class => 'disabled'
end
html_container(html) click to toggle source

@return [String] list of pagination links

# File lib/materialize_pagination/materialize_renderer.rb, line 8
def html_container(html)
  tag :div, tag(:ul, html, :class => "pagination"), class: 'row'
end
page_number(page) click to toggle source

@return [String] rendered pagination link

# File lib/materialize_pagination/materialize_renderer.rb, line 13
def page_number(page)
  classes = page == current_page ? 'active' : 'waves-effect'
  tag :li, link(page, page, :rel => rel_value(page)), :class => classes
end
previous_or_next_page(page, text, classname) click to toggle source

@return [String] rendered previous and next arrow links

# File lib/materialize_pagination/materialize_renderer.rb, line 24
def previous_or_next_page(page, text, classname)
  classes = [(classname if @options[:page_links]), (page ? 'waves-effect' : 'disabled')].join(' ')
  direction = classname == 'previous_page' ? :left : :right

  # Evaluate iconset selection and set the proper content for the link
  case WillPaginate::Materialize.configuration.iconset
  when :material_design
    link_structure = "<i class='material-icons'>chevron_#{direction}</i>"
  when :font_awesome
    link_structure = "<i class='fas fa-chevron-#{direction}'></i>"
  else
    link_structure = ""
    raise 'Iconset not found'
  end

  tag :li, link(link_structure.html_safe, page || '#!'), class: classes
end