Class: Kaminari::Helpers::Tag
- Inherits:
-
Object
- Object
- Kaminari::Helpers::Tag
- 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
When no matching template were found in your app, 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
-
#initialize(template, options = {}) ⇒ Tag
constructor
:nodoc:.
- #page_url_for(page) ⇒ Object
- #partial_path ⇒ Object
-
#to_s(locals = {}) ⇒ Object
:nodoc:.
Constructor Details
#initialize(template, options = {}) ⇒ Tag
:nodoc:
16 17 18 19 20 21 22 |
# File 'lib/kaminari/helpers/tags.rb', line 16 def initialize(template, = {}) #:nodoc: @template, @options = template, .dup @param_name = @options.delete(:param_name) || Kaminari.config.param_name @theme = @options.delete(:theme) @views_prefix = @options.delete(:views_prefix) @params = @options[:params] ? template.params.merge(@options.delete :params) : template.params end |
Instance Method Details
#page_url_for(page) ⇒ Object
28 29 30 |
# File 'lib/kaminari/helpers/tags.rb', line 28 def page_url_for(page) @template.url_for @params.merge(@param_name => (page <= 1 ? nil : page), :only_path => true) end |
#partial_path ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/kaminari/helpers/tags.rb', line 32 def partial_path [ @views_prefix, "kaminari", @theme, self.class.name.demodulize.underscore ].compact.join("/") end |
#to_s(locals = {}) ⇒ Object
:nodoc:
24 25 26 |
# File 'lib/kaminari/helpers/tags.rb', line 24 def to_s(locals = {}) #:nodoc: @template.render :partial => partial_path, :locals => @options.merge(locals), :formats => [:html] end |