Class: Pagination::Template
- Inherits:
-
Object
- Object
- Pagination::Template
- Defined in:
- lib/pagination/template.rb
Overview
This class can be used by itself, although there’s a ‘Pagination::Helper` available to provide convenience methods at your disposal.
Basic Usage:
collection = Pagination.paginate(dataset, :page => 1)
Pagination::Template.new(collection).render
Constant Summary collapse
- ROOT =
File.join(File.dirname(__FILE__), '..', '..', 'views')
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Class Method Summary collapse
-
.markup(type) ⇒ Object
This is used by the command line tool to spit out the markup.
Instance Method Summary collapse
-
#initialize(items) ⇒ Template
constructor
Initialize with your paginated collection.
-
#render ⇒ Object
Displayed the standard pagination markup as provided by the ‘Pagination` library.
Constructor Details
#initialize(items) ⇒ Template
Initialize with your paginated collection.
Paramaters:
- items
-
a ‘Pagination::Collection` object return by `Pagination.paginate`.
20 21 22 |
# File 'lib/pagination/template.rb', line 20 def initialize(items) @items = items end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
13 14 15 |
# File 'lib/pagination/template.rb', line 13 def items @items end |
Class Method Details
.markup(type) ⇒ Object
This is used by the command line tool to spit out the markup.
Parameters:
- type
-
either ‘haml’ or ‘erb’
Returns:
The actual markup source.
47 48 49 |
# File 'lib/pagination/template.rb', line 47 def self.markup(type) puts __send__(type) end |
Instance Method Details
#render ⇒ Object
Displayed the standard pagination markup as provided by the ‘Pagination` library.
This uses Haml if Haml is required already. Else it uses ERB.
Returns:
The actual HTML for the pagination.
31 32 33 34 35 36 37 |
# File 'lib/pagination/template.rb', line 31 def render if engine.respond_to?(:render) engine.render(Object.new, :items => items) else engine.result(binding) end end |