I have an array of objects that I am trying to display in categories using bootstrap panels. To get all of the different categories in the array I created a helper that loops through the array and returns an array of strings which contains all the different distinct categories.
Here are my two helpers:
Handlebars.registerHelper("GetFamilies", function (array) {
var families = [];
for (var i = 0; i < array.length; i++) {
var item = array[i];
if (families.indexOf(item.Family) <= -1) {
families.push(item.Family);
}
}
console.log("====================Families");
console.log(families);
return families;
});
Handlebars.registerHelper("GetFamiliyPieces", function (array, familyName) {
var result = _.filter(array, function (obj) {
// return true for every valid entry!
return obj.Family == familyName;
});
console.log("====================Family Pieces");
console.log(result);
return result;
});
Here is the html:
<div class="panel-group" id="toolbox-accordion">
{{#GetFamilies pieces}}
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#toolbox-accordion" href="#{{this}}">
{{this}}
</a>
</h4>
</div>
<div id="{{this}}" class="panel-collapse collapse in">
<div class="panel-body">
{{#GetFamilyPieces pieces this}}
<div class="toolbox_item" data-type="{{TypeName}}" data-type-id="{{TypeID}}" title="{{TypeDescription}}" data-input-count="{{Length Inputs}}" data-output-count="{{Length Outputs}}">
<span id="line"></span>
<div class='typename'>{{ShortName TypeName}}</div>
</div>
{{/GetFamilyPieces}}
</div>
</div>
</div>
{{/GetFamilies}}
</div>
In the Console I am hitting the GetFamilies Helper:
But not hitting the GetFamilyPieces helper.
My rendered HTML looks like this:
<div id="toolbox-container">
<div class="panel-group" id="toolbox-accordion">
Circuit,Component,Conductor </div>
</div>
As you can see it is just rendering a comma delimited string of what the array contains. Do you know why the full html is not being rendered?
