move some ActionView hacks back to Renderer class
This commit is contained in:
parent
ad6116b817
commit
0a80cda663
|
@ -35,12 +35,9 @@ module Kaminari
|
||||||
tags << (num_pages > current_page ? NextLink.new(self) : NextSpan.new(self))
|
tags << (num_pages > current_page ? NextLink.new(self) : NextSpan.new(self))
|
||||||
end
|
end
|
||||||
|
|
||||||
def context #:nodoc:
|
def partial_exists?(name) #:nodoc:
|
||||||
@template.instance_variable_get('@lookup_context')
|
resolver = context.instance_variable_get('@view_paths').first
|
||||||
end
|
resolver.find_all(*args_for_lookup(name)).present?
|
||||||
|
|
||||||
def resolver #:nodoc:
|
|
||||||
context.instance_variable_get('@view_paths').first
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s #:nodoc:
|
def to_s #:nodoc:
|
||||||
|
@ -52,6 +49,20 @@ module Kaminari
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
def context
|
||||||
|
@template.instance_variable_get('@lookup_context')
|
||||||
|
end
|
||||||
|
|
||||||
|
def args_for_lookup(name)
|
||||||
|
if (method = context.method :args_for_lookup).arity == 3
|
||||||
|
# 3.0
|
||||||
|
method.call name, 'kaminari', true
|
||||||
|
else
|
||||||
|
# 3.1
|
||||||
|
method.call name, 'kaminari', true, []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def method_missing(meth, *args, &blk)
|
def method_missing(meth, *args, &blk)
|
||||||
@template.send meth, *args, &blk
|
@template.send meth, *args, &blk
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,7 +36,7 @@ module Kaminari
|
||||||
# 2. a template for its parent class from app/views
|
# 2. a template for its parent class from app/views
|
||||||
# 3. the default one inside the engine
|
# 3. the default one inside the engine
|
||||||
def find_template(klass = self.class)
|
def find_template(klass = self.class)
|
||||||
if @renderer.resolver.find_all(*args_for_lookup(klass)).present?
|
if @renderer.partial_exists? klass.template_filename
|
||||||
"kaminari/#{klass.template_filename}"
|
"kaminari/#{klass.template_filename}"
|
||||||
elsif (parent = klass.ancestors[1]) == Tag
|
elsif (parent = klass.ancestors[1]) == Tag
|
||||||
"kaminari/#{self.class.template_filename}"
|
"kaminari/#{self.class.template_filename}"
|
||||||
|
@ -45,16 +45,6 @@ module Kaminari
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def args_for_lookup(klass)
|
|
||||||
if (method = @renderer.context.method :args_for_lookup).arity == 3
|
|
||||||
# 3.0
|
|
||||||
method.call klass.template_filename, 'kaminari', true
|
|
||||||
else
|
|
||||||
# 3.1
|
|
||||||
method.call klass.template_filename, 'kaminari', true, []
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def page_url_for(page)
|
def page_url_for(page)
|
||||||
@renderer.url_for @renderer.params.merge(:page => (page <= 1 ? nil : page))
|
@renderer.url_for @renderer.params.merge(:page => (page <= 1 ? nil : page))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue