module Locomotive module Steam module Liquid module Filters module Pagination # Render the navigation for a paginated collection def default_pagination(paginate, *args) return '' if paginate['parts'].empty? options = args_to_options(args) previous_link = default_pagination_next_or_previous_link(:previous, paginate, options, 'prev') next_link = default_pagination_next_or_previous_link(:next, paginate, options, 'next') links = default_pagination_links(paginate) %{} end private def default_pagination_links(paginate) paginate['parts'].map do |part| if part['is_link'] "#{part['title']}" elsif part['hellip_break'] "#{part['title']}" else "#{part['title']}" end end.join end def default_pagination_next_or_previous_link(type, paginate, options, css) label = options[:"#{type}_label"] || I18n.t("pagination.#{type}") if paginate[type.to_s].blank? "#{label}" else "#{label}" end end def default_pagination_url(url) url.starts_with?('/') ? url : "/#{url}" end end ::Liquid::Template.register_filter(Pagination) end end end end