Code: Select all
Error: You must pass a string or Handlebars AST to Handlebars.compile. You passed undefined
Code: Select all
{{#sets}}
[*]
{{title}}
[img]{{img}}[/img]
{{/sets}}
Here is the rest of it
HTML
[list]
{{#sets}}
[*]
{{title}}
[img]{{img}}[/img]
{{/sets}}
[/list]
jQuery
function getProductsSets() {
$.getJSON('products/products.json', {
format: "json"
}).done(function(json) {
$.each(json.sets, function() {
var source = $('#full-sets-template-mobile').html();
console.log(source)
var template = Handlebars.compile(source);
var data = template(json);
var html = $('#sets-template-inner').html(data);
});
}).fail(function() {
console.log('failed');
});
}
JSON
{
"sets":
[
{
"title": "raw bones",
"img": "img/sets/set1.jpg",
"desc": "Raw pine table with 2 chairs and a bench.",
"base": 1200,
"seating":
[
{
"price": 0,
"name": "4 seater"
},
{
"price": 400,
"name": "6 seater"
},
{
"price": 800,
"name": "8 seater"
}
]
},
{
"title": "sky blue",
"img": "img/sets/set1.jpg",
"desc": "Raw pine table with 2 chairs and a bench",
"base": 1300,
"seating":
[
{
"price": 0,
"name": "4 seater"
},
{
"price": 500,
"name": "6 seater"
},
{
"price": 800,
"name": "8 seater"
}
]
}
]
}