Closed kgrigor closed 8 months ago
Hi @kgrigor. Sorry for the late response. I just got back from vacation. Would you mind providing some more info on your use case and what you're trying to simplify?
Hi @jimf, I think @kgrigor 's additions is helpful when you want to implement say a search on a page using a GET request.
So for instance if I want to show the second page of a list of US schools located in Philadelphia, my URL will be: localhost/schools?location=philadelphia&page=2
But for simply displaying the second page of a list of US schools, it will be: localhost/schools?page=2
As with the current version.
I hope this presents a good use case.
I had the need to pass in URL so I don't have to add logic in every page where I also have search feature. Pull request introduces a feature where you can pass in URL to the helper and it will construct the correct URL and return its
href
, while maintaining other parameters you have in the URL.Usage:
href="{{ paginatedUrl }}"
instead ofhref="?page={{ n }}"
.http://localhost
, if you'd like to change it simply pass inurl
parameter topagination
hash, for example if you're using express:n
is still part of the returned object and can be used as necessary.