Pocoo

open source bulletin board


Template Extensions

Pocoo defines some extra Jinja? tags and filters for template designers.

{% paginate %}

The pagination tag renders a simple pagination for a Pagination object in the context.

Here the syntax: {% paginate variable link_schema, active_schema, commata, ellipsis[, threshold] %}

Here the parts explained:

variable the pagination object from the context
link_schema the schema for an linked page, not the current.
active_schema the schema for the current page.
commata a glue string for links
ellipsis a glue string for ommited links
threshold number of links shown from start, end and current page. defaults to 3

link_schema and active_schema can contain python string formatting with the following variables:

link link to the linked page
page number of the page
<div class="pagination">
  {% paginate forum.pagination
      '<a href="%(link)s">%(page)s</a>',
      '<strong>%(page)s</strong>',
      ', ',
      ' ... ',
      3
   %}
</div>

A result would look like this:

<div class="pagination">
  <a href="/forum/2/1">1</a>,
  <a href="/forum/2/2">2</a>,
  <a href="/forum/2/3">3</a> ...
  <a href="/forum/2/8">8</a>,
  <strong>9</strong>,
  <a href="/forum/2/10">10</a> ...
  <a href="/forum/2/13">13</a>,
  <a href="/forum/2/14">14</a>,
  <a href="/forum/2/15">15</a>
</div>

And here the rendered version:

1, 2, 3 ... 8, 9, 10 ... 13, 14, 15

|dateformat

A simple filter for formatting a datetime object in the context according to the user settings.

|timedeltaformat

Formats the difference between a datetime object and the current time or an datetime object and another one:

Last message: {{ forum.last_post.time|timedeltaformat }}

Difference: {{ forum.last_post.time|timedeltaformat forum.other_post.time }}

output:

Last message: 8 minutes ago. Difference: 15 days in the future.