Closed PhilippeHidayat closed 8 years ago
I'm not sure this really belongs in the helper, given that id
isn't changing anywhere and isn't really tied to any of the pagination logic. I'd recommend instead providing it with the rest of your template data and referencing it directly. For example:
var html = template({
id: myId,
pagination: {
page: 3,
pageCount: 10
}
});
{{#paginate pagination type="last"}}
<li id={{../id}}{{#if disabled}} class="disabled"{{/if}}><a href="?p={{n}}">Last</a></li>
{{/paginate}}
Let me know if I'm missing something.
I did tried referencing that "id" directly, but handlebars can't read it when it is placed between {{#paginate ...}} and {{/paginate}}. No idea why. Thats why i tried to pass it through the helper.
Ah, yes, that's the way Handlebars deals with scoping. When inside the paginate
block expression, the context changes. Note in my example that I'm using ../id
. That instructs the engine to use id
in the scope above. See the "Handlebars Paths" section of the official docs for more.
Closing due to inactivity. Feel free to reopen.
adding options "id" in-case the is link that use id in the pagination link