Class: Kaminari::Helpers::SinatraHelpers::ActionViewTemplateProxy
- Inherits:
-
ActionView::Base
- Object
- ActionView::Base
- Kaminari::Helpers::SinatraHelpers::ActionViewTemplateProxy
- Defined in:
- lib/kaminari/helpers/sinatra_helpers.rb
Overview
kaminari-sinatra uses Action View for rendering the Paginator because the default template uses Rails 3-ish ‘<%=` + block syntax that can’t be rendered with pure ERB.
Instance Method Summary collapse
-
#initialize(current_path: nil, param_name: nil, current_params: nil) ⇒ ActionViewTemplateProxy
constructor
A new instance of ActionViewTemplateProxy.
- #params ⇒ Object
- #url_for(params) ⇒ Object
Constructor Details
#initialize(current_path: nil, param_name: nil, current_params: nil) ⇒ ActionViewTemplateProxy
Returns a new instance of ActionViewTemplateProxy.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/kaminari/helpers/sinatra_helpers.rb', line 29 def initialize(current_path: nil, param_name: nil, current_params: nil) super() @current_path = current_path @param_name = param_name || Kaminari.config.page_method_name @current_params = current_params || {} @current_params.delete(@param_name) view_paths << SinatraHelpers.view_paths view_paths << File.join(Gem.loaded_specs['kaminari-core'].gem_dir, 'app/views') end |
Instance Method Details
#params ⇒ Object
52 53 54 |
# File 'lib/kaminari/helpers/sinatra_helpers.rb', line 52 def params @current_params end |
#url_for(params) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/kaminari/helpers/sinatra_helpers.rb', line 41 def url_for(params) return params if String === params extra_params = {} if (page = params[@param_name]) && (Kaminari.config.params_on_first_page || (page.to_i != 1)) extra_params[@param_name] = page end query = @current_params.merge(extra_params) @current_path + (query.empty? ? '' : "?#{query.to_query}") end |