Sha256: 4be18149fe55026b037fdf2faa2ce89f71179ad73dcf5ec6d3345f7d89753561

Contents?: true

Size: 1.24 KB

Versions: 27

Compression:

Stored size: 1.24 KB

Contents

module WillPaginate
  module ViewHelpers
    # This class does the heavy lifting of actually building the pagination
    # links. It is used by +will_paginate+ helper internally.
    class LinkRenderer < LinkRendererBase

    protected
    
      def page_number(page)
        unless page == current_page
          link(page, page, :rel => rel_value(page), :class => "btn")
        else
          tag(:a, page, :class => 'current active btn')
        end
      end
      
      def gap
        text = @template.will_paginate_translate(:page_gap) { '&hellip;' }
        %(<a class="gap btn disabled">#{text}</a>)
      end
      
      def previous_or_next_page(page, text, classname)
        if page
          link(text, page, :class => classname + ' btn')
        else
          tag(:a, text, :class => classname + ' disabled btn')
        end
      end
      
      def html_container(html)
        html
      end
      
    private

      def param_name
        @options[:param_name].to_s
      end

      def link(text, target, attributes = {})
        if target.is_a? Fixnum
          attributes[:rel] = rel_value(target)
          target = url(target)
        end
        attributes[:href] = target
        tag(:a, text, attributes)
      end

    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
beautiful_scaffold-0.3.3 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.3.2 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.3.1 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.3.0.rc6 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.3.0.rc5 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.3.0.rc4 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.3.0.rc3 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.3.0.rc2 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.3.0.rc1 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.3.0.pre lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.2.7 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.2.6 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.2.5 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.2.4 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.2.3 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.2.2 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.2.1 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.2.0 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.1.9 lib/generators/templates/app/initializers/link_renderer.rb
beautiful_scaffold-0.1.8 lib/generators/templates/app/initializers/link_renderer.rb