Created
September 25, 2012 08:54
-
-
Save MarkVaughn/3780719 to your computer and use it in GitHub Desktop.
jade pagination template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-// example pagination object | |
- var p = {current: 4, total: 10} | |
-// actual template | |
.paginationcontrol | |
- if(p.current > 1) | |
a.page.page-first(href=util.urlHelper({p:null})) << | |
a.page.page-prev(href=util.urlHelper({p:(p.current - 1)!=1?(p.current - 1): null})) < | |
- else | |
span.page.disabled.page-first << | |
span.page.disabled.page-prev < | |
- for(var i = p.current-2; i <= p.current + 2; ++i) | |
- if (i < p.total && i > 0) | |
- if (i !== p.current) | |
a.page(href=util.urlHelper({p:i!=1 ? i: null}))=i | |
- else | |
span.page.current=i | |
- if(p.current < p.total) | |
a.page-next(href=util.urlHelper({p:(p.current + 1)})) > | |
a.page-last(href=util.urlHelper({p:p.total})) >> | |
- else | |
span.page.disabled.page-next > | |
span.page.disabled.page-last >> |
Very helpful:heart:
Doesn't display the last page.
Should have - if (i <= p.total && i > 0)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice 👍