diff --git a/components/library/src/pagination/mod.rs b/components/library/src/pagination/mod.rs index 6a848f8..889e201 100644 --- a/components/library/src/pagination/mod.rs +++ b/components/library/src/pagination/mod.rs @@ -191,6 +191,7 @@ impl<'a> Paginator<'a> { ); paginator.insert("pages", to_value(¤t_pager.pages).unwrap()); paginator.insert("current_index", to_value(current_pager.index).unwrap()); + paginator.insert("total_pages", to_value(self.all_pages.len()).unwrap()); paginator } @@ -323,6 +324,7 @@ mod tests { assert_eq!(context["next"], to_value::>(None).unwrap()); assert_eq!(context["previous"], to_value("https://vincent.is/posts/").unwrap()); assert_eq!(context["current_index"], to_value(2).unwrap()); + assert_eq!(context["total_pages"], to_value(4).unwrap()); } #[test] diff --git a/docs/content/documentation/templates/pagination.md b/docs/content/documentation/templates/pagination.md index d6d4ed1..0c6c101 100644 --- a/docs/content/documentation/templates/pagination.md +++ b/docs/content/documentation/templates/pagination.md @@ -28,6 +28,8 @@ next: String?; pages: Array; // Which pager are we on current_index: Number; +// Total number of pages accross all the pagers +total_pages: Number; ``` A pager is a page of the pagination: if you have 100 pages and are paginating 10 by 10, you will have 10 pagers containing