Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/sayonab/pagination

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/sayonab/pagination

  • v0.0.0-20150914201838-4696331b5c9e
  • Source
  • Go
  • Socket score

Version published
Created
Source

Build Status Coverage Godoc license

Pagination

Pagination is a simple package that provides pagination. Has HTML support using the html/template package.

Installation

Install using go get.

$ go get github.com/SayonAB/pagination

Then import it in your project.

import "github.com/SayonAB/pagination"

Usage

Create a basic pagination and check the offset for current page

numPosts := db.Posts().Count()
postsPerPage := 25
currentPage := request.Query().Int("page")
p := pagination.New(numPosts, postsPerPage, currentPage)
fmt.Printf("The current offset is: %d\n", p.Offset()) // The current offset is: 75

Create a HTML pagination and use it in a html/template

p := pagination.NewHTML(110, 25, 2)
data := map[string]interface{}{
  "Pager": p,
}
var out bytes.Buffer
t := template.Must(template.New("pagination-test").Parse("{{ .Pager.Render }}"))
t.Execute(&out, data)
fmt.Printf("HTML list: %s\n", out.String())

Testing

Run the tests using go test.

$ go test

Contributing

All contributions are welcome! See CONTRIBUTING for more info.

License

Licensed under MIT license. See LICENSE for more information.

FAQs

Package last updated on 14 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc