Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds pagination to template engine #275

Closed
wants to merge 2 commits into from

Conversation

davidmerfield
Copy link
Owner

@davidmerfield davidmerfield commented Mar 25, 2020

Could we use this in combination with custom routes to allow the inclusion of paginated entries on other pages?

{{#paginate}}
  
  {{#posts}}
   <a href="{{{url}}}">{{{title}}}</a><br>
  {{/posts}}

  {{#next_page}}

  {{/next_page}}

  <p>Page: {{current_page}}</p>

  {{#previous_page}}

  {{/previous_page}}


{{/paginate}}

{{#posts_page}}

{{/posts_page}}

{{#posts_page.next}}
<a href="/page/{{next}}">Next posts</a>
{{/posts_page.next}}

This would generate a paginated list of posts:

{{#paginate}}

  {{#posts}}
  ...
  {{/posts}}

  {{#next}}
  <a href="{{.}"></a>
  {{/next}}

{{/paginate}}

This would list all the posts on the blog:

  {{#posts}}
  ...
  {{/posts}}

This would be ideal, but it's confusing with pages since they are a kind of entry:

{{#page}}
  {{#posts}}
  ...
  {{/posts}}
  {{#next}}
  ...
  {{/next}}
{{/page}}

Is there a bisyllabic word we could use instead of the trisyllabic word? There doesn't seem to be another way to say paginate. Foliate seems to be the other option, but that word is even more obscure.

posts_per_page: 10

What about making next, previous just properties of the posts array, and automatically paginate it?

  {{#posts}}
    ...
  {{/posts}}
  {{#posts.next_page}}
  <a href="page/{{posts.next}}">Next</a>
  {{/posts.next_page}}

@davidmerfield davidmerfield changed the title Adds new template tag: Paginate Adds Paginate template tag Mar 29, 2020
@davidmerfield davidmerfield changed the title Adds Paginate template tag Adds pagination to template engine Oct 9, 2020
@davidmerfield davidmerfield deleted the paginate-template-tag branch December 11, 2023 15:17
@davidmerfield davidmerfield restored the paginate-template-tag branch December 11, 2023 15:17
@davidmerfield davidmerfield deleted the paginate-template-tag branch December 11, 2023 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant