Please enable JavaScript to view this site.

The manual for the JobRouter developer

Handlebars provide the each-block to create a specific structure for each element of an array. This can be used, for example, to build lists.

Within the each block, placeholders are read out from the current object. The current object can be referenced via this. If a placeholder outside the object should be accessed within the loop, a path-like notation with ../ must be used. To handle empty arrays separately, an each-block can also contain an else-branch.

Template:

<ul>

{{#each authors}}

    <li>{{../nameLabel}} {{firstName}} {{lastName}}</li>

{{else}}

 No authors found

{{/each}}

</ul>

Data:

{

    authors: [{

        firstName: 'John',

        lastName: 'Doe'

    }, {

        firstName: 'Jane',

        lastName: 'Doe'

    }],

    nameLabel: 'Name:',

}

Result:

<ul>

    <li>Name: John Doe</li>

    <li>Name: Jane Doe</li>

</ul>