Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Jade + Bootstrap Pagination Mixin
//- Pagination mixin
//- ----------------
//- start=# to start pagination at
//- numPages=# links to serve up
//- base=base url before num
//-
//- Example:
//- pagination(3,5,4,'/fda/')
//- Yields: | « | 3 | 4 | 5 | 6 | 7 | » |
//- « = /fda/2, 3 = /fda/3, 4 = #, .. 7 = /fda/7, » = /fda/8
mixin pagination(start, numPages, curr, base)
- start = start || 1
- numPages = numPages || 10
- curr = curr || 1
- base = base || '#'
.pagination
ul
- if(curr==1)
li.disabled
a(href='#') Prev
- else
li
a(href='#') Prev
- for(var i=start;i<start+numPages;i++) {
- if(i==curr)
li.active
a(href='#{base}#{i}') #{i}
- else
li
a(href='#{base}#{i}') #{i}
- }
li
a(href='#') Next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment