From 0b3763cc6775d2b423002a0405d15d1a2e38ac1d Mon Sep 17 00:00:00 2001 From: Jens Bissinger Date: Tue, 7 Oct 2014 11:39:27 +0200 Subject: [PATCH] Cleanup pagination documentation. Refs #835. --- utils/pagination/controller.go | 49 ---------------------------- utils/pagination/doc.go | 59 ++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 49 deletions(-) create mode 100644 utils/pagination/doc.go diff --git a/utils/pagination/controller.go b/utils/pagination/controller.go index 5a0d4e99..da92bd69 100644 --- a/utils/pagination/controller.go +++ b/utils/pagination/controller.go @@ -12,55 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Usage -// -// In your beego.Controller: -// -// package controllers -// -// import "github.com/astaxie/beego/utils/pagination" -// -// type PostsController struct { -// beego.Controller -// } -// -// func (this *PostsController) ListAllPosts() { -// // sets this.Data["paginator"] with the current offset (from the url query param) -// postsPerPage := 20 -// paginator := pagination.SetPaginator(this, postsPerPage, CountPosts()) -// -// // fetch the next 20 posts -// this.Data["posts"] = ListPostsByOffsetAndLimit(paginator.Offset(), postsPerPage) -// } -// -// -// In your view templates: -// -// {{if .paginator.HasPages}} -// -// {{end}} -// -// See also http://beego.me/docs/mvc/view/page.md package pagination import ( diff --git a/utils/pagination/doc.go b/utils/pagination/doc.go new file mode 100644 index 00000000..db8cd57e --- /dev/null +++ b/utils/pagination/doc.go @@ -0,0 +1,59 @@ +/* + +The pagination package provides utilities to setup a paginator within the +context of a http request. + +Usage + +In your beego.Controller: + + package controllers + + import "github.com/astaxie/beego/utils/pagination" + + type PostsController struct { + beego.Controller + } + + func (this *PostsController) ListAllPosts() { + // sets this.Data["paginator"] with the current offset (from the url query param) + postsPerPage := 20 + paginator := pagination.SetPaginator(this, postsPerPage, CountPosts()) + + // fetch the next 20 posts + this.Data["posts"] = ListPostsByOffsetAndLimit(paginator.Offset(), postsPerPage) + } + + +In your view templates: + + {{if .paginator.HasPages}} + + {{end}} + +See also + +http://beego.me/docs/mvc/view/page.md + +*/ +package pagination