Skip to content

Instantly share code, notes, and snippets.

@backus
Last active August 14, 2018 08:30
Show Gist options
  • Save backus/5087360 to your computer and use it in GitHub Desktop.
Save backus/5087360 to your computer and use it in GitHub Desktop.
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
@mehdiq6
Copy link

mehdiq6 commented Aug 14, 2018

oO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment