class Kaminari::Helpers::SinatraHelpers::ActionViewTemplateProxy
Public Class Methods
new(opts={})
click to toggle source
# File lib/kaminari/helpers/sinatra_helpers.rb, line 30 def initialize(opts={}) @current_path = opts[:current_path] @param_name = (opts[:param_name] || :page).to_sym @current_params = opts[:current_params] @current_params.delete(@param_name) end
Public Instance Methods
link_to_unless(condition, name, options = {}, html_options = {}, &block)
click to toggle source
# File lib/kaminari/helpers/sinatra_helpers.rb, line 54 def link_to_unless(condition, name, options = {}, html_options = {}, &block) options = url_for(options) if options.is_a? Hash if condition if block_given? block.arity <= 1 ? capture(name, &block) : capture(name, options, html_options, &block) else name end else link_to(name, options, html_options) end end
params()
click to toggle source
# File lib/kaminari/helpers/sinatra_helpers.rb, line 67 def params @current_params end
render(*args)
click to toggle source
# File lib/kaminari/helpers/sinatra_helpers.rb, line 37 def render(*args) base = ActionView::Base.new.tap do |a| a.view_paths << SinatraHelpers.view_paths a.view_paths << File.expand_path('../../../../app/views', __FILE__) end base.render(*args) end
url_for(params)
click to toggle source
# File lib/kaminari/helpers/sinatra_helpers.rb, line 45 def url_for(params) extra_params = {} if page = params[@param_name] and page != 1 extra_params[@param_name] = page end query = @current_params.merge(extra_params) @current_path + (query.empty? ? '' : "?#{query.to_query}") end