class Kaminari::Helpers::Tag
A tag stands for an HTML tag inside the paginator. Basically, a tag has its own partial template file, so every tag can be rendered into String using its partial template.
The template file should be placed in your app/views/kaminari/ directory with underscored class name (besides the “Tag” class. Tag
is an abstract class, so _tag parital is not needed).
e.g.) PrevLink -> app/views/kaminari/_prev_link.html.erb
If the template file does not exist, it falls back to ancestor classes.
e.g.) FirstPageLink -> app/views/kaminari/_first_page_link.html.erb -> app/views/kaminari/_page_link.html.erb
When no matching template were found in your app, finally the engine's pre installed template will be used.
e.g.) Paginator -> $GEM_HOME/kaminari-x.x.x/app/views/kaminari/_paginator.html.erb
Private Class Methods
ancestor_renderables()
click to toggle source
# File lib/kaminari/helpers/tags.rb, line 30 def self.ancestor_renderables arr = [] ancestors.each do |klass| return arr if klass == Tag arr << klass if klass != Renderable end end
Private Instance Methods
find_template()
click to toggle source
OMG yet another super dirty hack this method finds
1. a template for the given class from app/views 2. a template for its parent class from app/views 3. the default one inside the engine
# File lib/kaminari/helpers/tags.rb, line 43 def find_template self.class.ancestor_renderables.each do |klass| return "kaminari/#{klass.template_filename}" if @template.partial_exists? klass.template_filename end "kaminari/#{self.class.template_filename}" end
page_url_for(page)
click to toggle source
# File lib/kaminari/helpers/tags.rb, line 50 def page_url_for(page) @template.url_for @template.params.merge(@param_name => (page <= 1 ? nil : page)) end