Client Side Template
{*empty}{/*empty}
Description
Displays alternative text when an array contains no entries.
If an array does not contain any entries you can specify alternative text to display. This is done using the {*empty}...{/*empty} directive. The text inside the {*empty} directives will be displayed in the event that an array contains no data. For example, consider the following sample data:
{ employees: [ {firstname: 'Fred', lastname: 'Smith', skills: [ {name: 'Javascript'},{name: 'CSS'}]}, {firstname: 'Laura', lastname: 'Linneker', skills: [{name: 'Xbasic'}]}, {firstname: 'Junior', lastname: 'Programmer', skills: [] } ] }
Notice that only the last array instances does not have any rows in the skills array. If the skills array is empty, we would like to print "No skills yet". Otherwise, we would like to display a list of skills and the total number of skills an employee has. The template defined below demonstrates how this is done:
{employees} Employee name: {firstname} {lastname}<br> <div> {skills} {*empty} No skills yet {/*empty} Skill Name: {name} {/skills} </div><br> {/employees}
Result:
Employee name: Fred Smith Skill Name: Javascript Skill Name: CSS Employee name: Laura Linneker Skill Name: Xbasic Employee name: Junior Programmer No skills yet
here