pager

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const Key = "p"

Variables

This section is empty.

Functions

func GetCurrentPageNumber

func GetCurrentPageNumber(pageNumber int) (int, bool)

GetCurrentPageNumber returns the page number of the current page, and true if a valid page number was provided.

func GetOffset

func GetOffset(pageNumber int, perPage int) int

GetOffset returns the offset for a LIMIT query for page pageNumber if there are perPage items per page.

func GetPageCount

func GetPageCount(n int, perPage int) int

GetPageCount returns the number of pages needed to fit n items if there are perPage items per page. If there are no items then that's still 1 page needed to show nothing.

Types

type State

type State struct {
	CurrentPage     int
	TotalPages      int
	FirstPageURL    string
	NextPageURL     string
	PreviousPageURL string
	LastPageURL     string
}

func GetState

func GetState(pageNumber int, pageCount int, basePath string, qs map[string]string) (*State, error)

GetState returns an instance of *State with paging information the template needs to render the paging navigation (p/pager/nav.go.html), or an error if basePath could not be parsed.

This method will not modify qs. Pass nil for qs if no additional parameters are needed.

Jump to

Keyboard shortcuts

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