olalonde / handlebars-paginate Goto Github PK
View Code? Open in Web Editor NEWPagination helper for Handlebars.
Home Page: http://syskall.com/pagination-with-handlebars/
Pagination helper for Handlebars.
Home Page: http://syskall.com/pagination-with-handlebars/
Hello,
Thank you for your work.
You need to put the dependencies in the bower.json file.
Otherwise, the files may be appended in the wrong order when using build tools.
Regards,
Jimmy
Please make your project available via Bower
bower install handlebars-paginate
Just giving this another shot and I'm getting the following
ReferenceError: template is not defined
I have the following
app.js
const paginate = require('handlebars-paginate');
hbs.registerHelper('paginate', paginate);
index.hbs
<nav aria-label="Page navigation">
<ul class="pagination">
{{#paginate pagination type="first"}}
<li class="page-item{{#if disabled}} disabled{{/if}}">
<a class="page-link" href="?page={{n}}" aria-label="First">
<span aria-hidden="true">«</span>
<span class="sr-only">First</span>
</a>
</li>
{{/paginate}}
{{#paginate pagination type="previous"}}
<li class="page-item{{#if disabled}} disabled{{/if}}">
<a class="page-link" href="?page={{n}}" aria-label="Previous">
<span aria-hidden="true">‹</span>
<span class="sr-only">Previous</span>
</a>
</li>
{{/paginate}}
{{#paginate pagination type="middle" limit="10"}}
<li class="page-item"><a class="page-link{{#if disabled}} disabled{{/if}}" href="?page={{n}}">{{n}}</a></li>
{{/paginate}}
{{#paginate pagination type="next"}}
<li class="page-item{{#if disabled}} disabled{{/if}}">
<a class="page-link" href="?page={{n}}" aria-label="Next">
<span aria-hidden="true">›</span>
<span class="sr-only">Next</span>
</a>
</li>
{{/paginate}}
{{#paginate pagination type="last"}}
<li class="page-item{{#if disabled}} disabled{{/if}}">
<a class="page-link" href="?page={{n}}" aria-label="Last">
<span aria-hidden="true">»</span>
<span class="sr-only">Last</span>
</a>
</li>
{{/paginate}}
</ul>
</nav>
routes.js
router.get('/dashboard', ensureAuthenticated, (req, res) => {
const html = template({pagination: {
page: parseInt(req.query.page) || 1,
pageCount: parseInt(req.query.limit) || 6
}});
User.find({}, function(err, users) {
res.render('dashboard/index.hbs', {
pageTitle: 'Dashboard',
users: users,
pagination: {
page: page,
pageCount: pageCount
}
});
});
});
<a class="page-link" href="/blog/category/{{category}}/{{n}}" aria-label="First">
i have this variable never shows up inside the pagination
{{category}}
please refer to this : https://stackoverflow.com/questions/46485384/handlebars-pagination-adding-custom-links
is there way I can ship my code with the handlebars-paginate javascript ? I dont wanna use npm to install it.
Hello, I have included extension in my project and got it working.
I have limited my 11 page layout to 5 and included previous and next as outermost links.
Also I have included first and last as [ ... ] links that appear notifying the user that there are more pages available in that direction.
Initial layout looks like this:
This works fine. However once I leave page nr.1 and go to nr.2 - first link activates and essentially I have double link to first page:
Once nr.4 is reached this again is valid because page nr.1 disappears from view:
As we are getting to the end - and last 4 pages are active similar issue appears on the right side - with nr.11 and last [...] page:
So my question is regarding this issue - is it possible to disable first and last links until they are really needed and first and last are actually out of the view? I have tried accessing (current)page in attempt to check if offset is reached, however page variable is not available to first and last - inside the pagination object.
Any solution for this?
Thank you.
Without a license no-one can knows if they're actually allowed to reuse this code.
Can you add a LICENSE file to the repo?
Prev and Next Buttons are not working Properly
Just working for 1 increment or 1 decrement with current page that passed from pagination.
eg:- pagination: { page:5 }
then
next is working up to 6
prievious is working up to 4
{{#paginate pagination type="previous"}}
<li {{#if disabled}}class="disabled"{{/if}}>Prev
{{/paginate}}
{{#paginate pagination type="next"}}
<li {{#if disabled}}class="disabled"{{/if}}>Next
{{/paginate}}
Am I missing a step?
Added this to my cotroller and passing: pagination: {page: page, pageCount: count}
First Prev NaN NaN NaN NaN NaN NaN NaN Next Last
Please give me simple example of plugin?
Here is my users page
https://gyazo.com/981af3a4c3c065ba4f31c055c2fd5977
As you can see I only have two users here so ideally only one button in the pagination should show here.
In the production app I have 20 users and I have limited the page to only show 6 records in the using the page prefix in the pagination settings however I am still getting 10 pages in the pagination.
Can this be dynamic so the right about of pages in the pagination given the amount of records created?
According to the README, handlebars-paginate is licensed under MIT, but the package.json says BSD.
Hi,
i am experiencing some strange behaviour
this module works absolutely perfect in development (localhost) BUT in heroku seems to not read this module
I have in my HELPERS folder this:
const hbs = require('hbs');
const paginate = require('handlebars-paginate');
hbs.registerHelper('paginate', paginate);
I noticed some TS warning about @types but i am not working in typescript so...
Could you help me?
Hello, where is the class named pagination-centered
I'm looking for a solution to paginate a handlebars template. I don't see how you apply this page number helper to the template that has the data. Any suggestions or examples?
Thanks,
Donnie
i am trying to include in
<a {{#if disabled}}class="disabled"{{/if}} href="?page={{n}}"><li>First</li></a>
something like:
<a {{#if disabled}}class="disabled"{{/if}} href="{{#if state}}?state={{state}}&{{/if}} {{#unless state}}?{{/state}}page={{n}}"><li>First</li></a>
could you help me to solve that?
thanks for your time and code!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.