mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
Remove the need to call #presence to show a fall-back HTML
Right now, the #paginate method doesn't show anything when there's only one page. While this is expected, some times there's a case where showing a fall back message is appropriate. In order to do so, a subsequent #presence call is needed because the #paginate method always returns a string. This commit adds a #presence call to the #render method, so it'll be a little cleaner to show a fall-back message. related: https://github.com/kaminari/kaminari/pull/785
This commit is contained in:
parent
4ada38c911
commit
a781f644ac
1 changed files with 5 additions and 1 deletions
|
@ -26,7 +26,11 @@ module Kaminari
|
|||
# render given block as a view template
|
||||
def render(&block)
|
||||
instance_eval(&block) if @options[:total_pages] > 1
|
||||
@output_buffer
|
||||
|
||||
# This allows for showing fall-back HTML when there's only one page:
|
||||
#
|
||||
# <%= paginate(@search_results) || "Showing all search results" %>
|
||||
@output_buffer.presence
|
||||
end
|
||||
|
||||
# enumerate each page providing PageProxy object as the block parameter
|
||||
|
|
Loading…
Reference in a new issue