paginator

package
v0.0.0-...-b75375f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2014 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CURRENT   = 1 << 0
	DISABLED  = 1 << 1
	SEPARATOR = 1 << 2
	PREVIOUS  = 1 << 3
	NEXT      = 1 << 4
)

Variables

View Source
var (
	DefaultOffset = 5
)

Functions

This section is empty.

Types

type Func

type Func func(base string, page int) string

Func receives the base URL (which might be relative or absolute) and the page number and returns the URL for the requested page number, as a string.

func Fmt

func Fmt(format string) Func

Fmt returns a function which returns the base URL for the first page and then fmt.Sprintf(format, base, page) for other pages.

type Pager

type Pager interface {
	Root() *html.Node
	Href(base string, page int) string
	Node(n *html.Node, page int, flags int) *html.Node
}

type Paginator

type Paginator struct {
	Base            string
	Current         int
	Count           int
	Offset          int
	Pager           Pager
	AlwaysShowFirst bool
	AlwaysShowLast  bool
}

func New

func New(base string, current, count int, pager Pager) *Paginator

func NewSimple

func NewSimple(base string, current, count int, next, prev, sep string, f Func) *Paginator

func (*Paginator) Render

func (p *Paginator) Render() template.HTML

type SimplePager

type SimplePager struct {
	Tag            string
	Wrapper        string
	Next           string
	Prev           string
	Separator      string
	NextClass      string
	PrevClass      string
	CurrentClass   string
	DisabledClass  string
	SeparatorClass string
	Func           Func
}

func (*SimplePager) Href

func (p *SimplePager) Href(base string, page int) string

func (*SimplePager) Node

func (p *SimplePager) Node(n *html.Node, page int, flags int) *html.Node

func (*SimplePager) Root

func (p *SimplePager) Root() *html.Node

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL