Skip to content

Instantly share code, notes, and snippets.

@MarkVaughn
Created September 25, 2012 08:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkVaughn/3780719 to your computer and use it in GitHub Desktop.
Save MarkVaughn/3780719 to your computer and use it in GitHub Desktop.
jade pagination template
-// 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)})) &gt;
a.page-last(href=util.urlHelper({p:p.total})) &gt;&gt;
- else
span.page.disabled.page-next &gt;
span.page.disabled.page-last &gt;&gt;
@sapher
Copy link

sapher commented Mar 13, 2016

Nice 👍

@ifndefdeadmau5
Copy link

Very helpful:heart:

@lexod
Copy link

lexod commented Sep 20, 2016

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