Download

{{reverse}} helper

The {{reverse}} helper is useful if you need to reverse items in a specific collection e.g. tags listing.

Syntax:

{{reverse collection}}

Example:

{{#each @website.contentStructure.tags}}
   {{#checkIf this.name '==' 'test'}}
      {{#if this.postsNumber}}
         {{reverse this.posts}}
         {{#each this.posts}} {{! this output is reversed }}
            {{title}}
         {{/each}}           
         {{reverse this.posts}}
      {{else}}
         There are no posts connected with tag name "test"
      {{/if}}
   {{/checkIf}}
{{/each}}

Important! You should restore original ordering after use of the modified output. That's why our example contains double call of the {{reverse}} helper - the first call reverse the order of elements and after getting a reversed output we reverse the collection again to get original ordering.

 

What are you waiting for?

Start building your site today.

  1. 1 Download Publii
  2. 2 Write your content
  3. 3 Publish your site
Create website