Class: Kaminari::Helpers::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/kaminari/helpers/tags.rb

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(template, options = {}) ⇒ Tag

:nodoc:



20
21
22
23
# File 'lib/kaminari/helpers/tags.rb', line 20

def initialize(template, options = {}) #:nodoc:
  @template, @options = template, template.options.merge(options)
  @param_name = @options.delete :param_name
end

Instance Method Details

#to_s(locals = {}) ⇒ Object

:nodoc:



25
26
27
# File 'lib/kaminari/helpers/tags.rb', line 25

def to_s(locals = {}) #:nodoc:
  @template.render :partial => find_template, :locals => @options.merge(locals)
end