module Pagy::Frontend

def pagy_link_proc(pagy, link_extra: '')

Benchmarked on a 20 link nav: it is ~22x faster and uses ~18x less memory than rails' link_to
Return a performance optimized proc to generate the HTML links
def pagy_link_proc(pagy, link_extra: '')
  p_prev      = pagy.prev
  p_next      = pagy.next
  left, right = %(<a href="#{pagy_url_for(pagy, PAGE_PLACEHOLDER, html_escaped: true)}" #{
                    pagy.vars[:link_extra]} #{link_extra}).split(PAGE_PLACEHOLDER, 2)
  lambda do |page, text = pagy.label_for(page), extra_attrs = ''|
    %(#{left}#{page}#{right}#{ case page
                               when p_prev then ' rel="prev"'
                               when p_next then ' rel="next"'
                               else             ''
                               end } #{extra_attrs}>#{text}</a>)
  end
end