Is it possible to bind multiple JSON objects in Mustache? I have a little app where I use backbone to extract data from a restful api.
I'm essentially getting a list of employees, and then all of their subordinates. I am passing the model to mustache and binding like this:
render: function(){
//debugger;
var model = {
manager: this.model.toJSON(),
subordinates: this.model.reports.toJSON()
}
console.log('render',this.model.toJSON()); // show the employee and the list of subordinates
this.el.innerHTML = Mustache.to_html(this.template, { employee_detail: model });
}
My template looks like below. It works fine for binding and displaying the manager variables, but the subordinates variables don't show up. I want to display an employee's details and then list all of their subordinates.
{{#employee_detail}}
<h3>{{manager.firstName}} {{manager.lastName}}</h3>
<h4>{{manager.title}}</h4>
<table class="table table-striped">
{{#manager.managerId}}
<tr>
<td>Manager:</td>
<td><i class="icon-user"></i> <a href='#employees/{{manager.managerId}}'>{{manager.managerName}}</a></td>
</tr>
{{/manager.managerId}}
<tr>
<td>Office Phone:</td>
<td><i class="icon-home"></i> {{manager.officePhone}}</td>
</tr>
<tr>
<td>Cell Phone:</td>
<td><i class="icon-headphones"></i> {{manager.cellPhone}}</td>
</tr>
<tr>
<td>Email:</td>
<td><i class="icon-envelope"></i> <a href="mailto:{{manager.email}}">{{manager.email}}</a></td>
</tr>
<tr>
<td>Twitter:</td>
<td><i class="icon-retweet"></i> <a href="">{{manager.twitterId}}</a></td>
</tr>
</table>
<table>
<tr>
<td>Subordinates:</td>
<td><i class="icon-user"></i> <a href='#employees/{{subordinates.id}}'>{{subordinates.fullName}}</a>
</td>
</tr>
</table>
{{/employee_detail}}