UNPKG

apostrophe

Version:

Apostrophe is a user-friendly content management system. This core module of Apostrophe provides rich content editing and essential facilities to integrate Apostrophe into your Express project. Apostrophe also includes simple facilities for storing your r

49 lines (42 loc) 1.85 kB
{# Output an easily styled classic pager, if needed #} {# ACHTUNG: the math was done pretty carefully to accommodate 5 links in the pager. #} {# If you want more you'll have to hunt down the right changes. This would be easier #} {# if 'let' statements really worked in nunjucks. TODO: when they update nunjucks, #} {# rework this. Also note aposPageRange which is only necessary because range() seems #} {# busted in this release of nunjucks #} {% macro renderPager(options, url) %} {% if ((options.page > 1) or (options.total > 1)) %} <div class="apos-pager"> {{ pagerPage(1, options, url) }} {% if options.page > 4 %} <span class="apos-pager-gap">&hellip;</span> {% endif %} {% for page in aposPageRange({ page: options.page, total: options.total, shown: 5 }) %} {{ pagerPageInner(page, options, url) }} {% endfor %} {% if options.page < (options.total - 3) %} <span class="apos-pager-gap">&hellip;</span> {% endif %} {{ pagerPage(options.total, options, url) }} </div> {% endif %} {% endmacro %} {% macro pagerPageInner(page, options, url) %} {% if ((page > 1) and (page < options.total)) %} {{ pagerPage(page, options, url) }} {% endif %} {% endmacro %} {% macro pagerPage(page, options, url) %} {% if (page <= options.total) %} <span class="apos-pager-number {% if page == 1 %}apos-first{% endif %} {% if page == options.total %}apos-last{% endif %} {% if page == options.page %}apos-active{% endif %}"> {%- if (options.page != page) -%} {# Dual markup for javascript applicatons and plain old links #} <a data-page="{{ page }}" href="{{ url | build({ page: page }) }}"> {%- endif -%} {{ page }} {%- if (options.page != page) -%} </a> {%- endif -%} </span> {% endif %} {% endmacro %}