Skip to content Skip to sidebar Skip to footer

Iterating Over Array Of Objects In Handlebars

I'm actually doing this in a JSON object but for this question, I will simplify. I can't seem to get my Handlebars template to build correctly. Here is a sample array of objects th

Solution 1:

Check this jsfiddle: http://jsfiddle.net/KPCh4/

var source = $("#document-template").html();
var template = Handlebars.compile(source);
var html = template(data);
$('#DocumentResults').html(html);

I were still focused on {{#each}} for iteration; # is a shortcut actually. Do not confuse {{Category}} and {{#Category}}. The former output a property's value; the latter is a list (see the #).

I let you fine-grained the snippet :)

Hope this helps,

R.

Post a Comment for "Iterating Over Array Of Objects In Handlebars"