[%- USE scalar -%] [%- WRAPPER site_wrapper.html title = 'Categories' -%] [%- SET p = c.req.query_params result = list_categories( p ) categories = result.rows -%]
[% IF result.total > 0 %]
[% IF result.params.sort == 'alphabetical' %]

### Categories (alphabetical)

Sort by popularity [% ELSIF result.params.sort == 'recent' %]

### Categories (most recently used)

Sort alphabetically [% ELSE %]

### Categories (by popularity)

Sort by most recent [% END %]

[% FOREACH category IN categories %]
- [% category.name %] ([% category.posts_count %])
[% END %]

[% ELSE %]

#### No categories found.

[% END %]
[% END %]