Skip to content

Commit

Permalink
removed EMPTY constant used for legacy compatibility with frozen_stri…
Browse files Browse the repository at this point in the history
…ng_literal
  • Loading branch information
ddnexus committed Mar 8, 2021
1 parent b826f61 commit 49040fb
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/pagy/extras/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module Frontend
def pagy_bootstrap_nav(pagy)
link, p_prev, p_next = pagy_link_proc(pagy, 'class="page-link"'), pagy.prev, pagy.next

html = EMPTY + (p_prev ? %(<li class="page-item prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</li>)
: %(<li class="page-item prev disabled"><a href="#" class="page-link">#{pagy_t('pagy.nav.prev')}</a></li>))
html = (p_prev ? %(<li class="page-item prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</li>)
: %(<li class="page-item prev disabled"><a href="#" class="page-link">#{pagy_t('pagy.nav.prev')}</a></li>))
pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
html << if item.is_a?(Integer); %(<li class="page-item">#{link.call item}</li>) # page link
elsif item.is_a?(String) ; %(<li class="page-item active">#{link.call item}</li>) # active page
Expand Down
4 changes: 2 additions & 2 deletions lib/pagy/extras/foundation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module Frontend
def pagy_foundation_nav(pagy)
link, p_prev, p_next = pagy_link_proc(pagy), pagy.prev, pagy.next

html = EMPTY + (p_prev ? %(<li class="prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</li>)
: %(<li class="prev disabled">#{pagy_t('pagy.nav.prev')}</li>))
html = +(p_prev ? %(<li class="prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</li>)
: %(<li class="prev disabled">#{pagy_t('pagy.nav.prev')}</li>))
pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
html << if item.is_a?(Integer); %(<li>#{link.call item}</li>) # page link
elsif item.is_a?(String) ; %(<li class="current">#{item}</li>) # active page
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy/extras/items.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def pagy_items_selector_js(pagy, id=pagy_id)
link = pagy_marked_link(pagy_link_proc(pagy))
p_vars[:items] = p_items # restore the items

html = EMPTY + %(<span id="#{id}">)
html = %(<span id="#{id}">)
input = %(<input type="number" min="1" max="#{p_vars[:max_items]}" value="#{p_items}" style="padding: 0; text-align: center; width: #{p_items.to_s.length+1}rem;">)
html << %(#{pagy_t('pagy.items_selector_js', item_name: pagy_t(p_vars[:i18n_key], count: p_items), items_input: input, count: p_items)})
html << %(</span>#{pagy_json_tag(:items_selector, id, pagy.from, link, defined?(TRIM) && p_vars[:page_param])})
Expand Down
4 changes: 2 additions & 2 deletions lib/pagy/extras/materialize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ module Frontend
# Pagination for materialize: it returns the html with the series of links to the pages
def pagy_materialize_nav(pagy)
link, p_prev, p_next = pagy_link_proc(pagy), pagy.prev, pagy.next
html = EMPTY + (p_prev ? %(<li class="waves-effect prev">#{link.call p_prev, '<i class="material-icons">chevron_left</i>', 'aria-label="previous"'}</li>)
: %(<li class="prev disabled"><a href="#"><i class="material-icons">chevron_left</i></a></li>))
html = (p_prev ? %(<li class="waves-effect prev">#{link.call p_prev, '<i class="material-icons">chevron_left</i>', 'aria-label="previous"'}</li>)
: +%(<li class="prev disabled"><a href="#"><i class="material-icons">chevron_left</i></a></li>))
pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
html << if item.is_a?(Integer); %(<li class="waves-effect">#{link.call item}</li>) # page link
elsif item.is_a?(String) ; %(<li class="active">#{link.call item}</li>) # active page
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy/extras/navs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def pagy_nav_js(pagy, id=pagy_id)
def pagy_combo_nav_js(pagy, id=pagy_id)
link, p_prev, p_next, p_page, p_pages = pagy_link_proc(pagy), pagy.prev, pagy.next, pagy.page, pagy.pages

html = EMPTY + %(<nav id="#{id}" class="pagy-combo-nav-js pagination" role="navigation" aria-label="pager">)
html = %(<nav id="#{id}" class="pagy-combo-nav-js pagination" role="navigation" aria-label="pager">)
html << (p_prev ? %(<span class="page prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</span> )
: %(<span class="page prev disabled">#{pagy_t('pagy.nav.prev')}</span> ))
input = %(<input type="number" min="1" max="#{p_pages}" value="#{p_page}" style="padding: 0; text-align: center; width: #{p_pages.to_s.length+1}rem;">)
Expand Down
6 changes: 3 additions & 3 deletions lib/pagy/extras/semantic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module Frontend
def pagy_semantic_nav(pagy)
link, p_prev, p_next = pagy_link_proc(pagy, 'class="item"'), pagy.prev, pagy.next

html = EMPTY + (p_prev ? %(#{link.call p_prev, '<i class="left small chevron icon"></i>', 'aria-label="previous"'})
: %(<div class="item disabled"><i class="left small chevron icon"></i></div>))
html = (p_prev ? %(#{link.call p_prev, '<i class="left small chevron icon"></i>', 'aria-label="previous"'})
: +%(<div class="item disabled"><i class="left small chevron icon"></i></div>))
pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
html << if item.is_a?(Integer); %(#{link.call item}) # page link
elsif item.is_a?(String) ; %(<a class="item active">#{item}</a>) # current page
Expand Down Expand Up @@ -41,7 +41,7 @@ def pagy_semantic_nav_js(pagy, id=pagy_id)
def pagy_semantic_combo_nav_js(pagy, id=pagy_id)
link, p_prev, p_next, p_page, p_pages = pagy_link_proc(pagy, 'class="item"'), pagy.prev, pagy.next, pagy.page, pagy.pages

html = EMPTY + %(<div id="#{id}" class="pagy-semantic-combo-nav-js ui compact menu" role="navigation" aria-label="pager">)
html = %(<div id="#{id}" class="pagy-semantic-combo-nav-js ui compact menu" role="navigation" aria-label="pager">)
html << (p_prev ? %(#{link.call p_prev, '<i class="left small chevron icon"></i>', 'aria-label="previous"'})
: %(<div class="item disabled"><i class="left small chevron icon"></i></div>))
input = %(<input type="number" min="1" max="#{p_pages}" value="#{p_page}" style="padding: 0; text-align: center; width: #{p_pages.to_s.length+1}rem; margin: 0 0.3rem">)
Expand Down
4 changes: 2 additions & 2 deletions lib/pagy/extras/uikit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def pagy_uikit_nav(pagy)
link, p_prev, p_next = pagy_link_proc(pagy), pagy.prev, pagy.next

previous_span = "<span uk-pagination-previous>#{pagy_t('pagy.nav.prev')}</span>"
html = EMPTY + (p_prev ? %(<li>#{link.call p_prev, previous_span}</li>)
: %(<li class="uk-disabled"><a href="#">#{previous_span}</a></li>))
html = (p_prev ? %(<li>#{link.call p_prev, previous_span}</li>)
: %(<li class="uk-disabled"><a href="#">#{previous_span}</a></li>))
pagy.series.each do |item|
html << if item.is_a?(Integer); %(<li>#{link.call item}</li>)
elsif item.is_a?(String) ; %(<li class="uk-active"><span>#{item}</span></li>)
Expand Down
5 changes: 2 additions & 3 deletions lib/pagy/frontend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ module Frontend

include Helpers

EMPTY = '' # EMPTY + 'string' is almost as fast as +'string' but is also 1.9 compatible
MARK = PAGE_PLACEHOLDER # backward compatibility in case of helper-overriding in legacy apps

# Generic pagination: it returns the html with the series of links to the pages
def pagy_nav(pagy)
link, p_prev, p_next = pagy_link_proc(pagy), pagy.prev, pagy.next

html = EMPTY + (p_prev ? %(<span class="page prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</span> )
: %(<span class="page prev disabled">#{pagy_t('pagy.nav.prev')}</span> ))
html = (p_prev ? %(<span class="page prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</span> )
: %(<span class="page prev disabled">#{pagy_t('pagy.nav.prev')}</span> ))
pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
html << if item.is_a?(Integer); %(<span class="page">#{link.call item}</span> ) # page link
elsif item.is_a?(String) ; %(<span class="page active">#{item}</span> ) # current page
Expand Down

0 comments on commit 49040fb

Please sign in to comment.