I have function which return JSON:
Template.mainmenu.menuitem = function() {
var jsonObj = { items: [
{ url: "http://google.com", title: "google" },
{ url: "http://stackoverflow.com", title: "stackoverflow" },
] };
return jsonObj;
};
And I have custom handlebars helper:
Handlebars.registerHelper('woodoo', function(context, options) {
var ret = "";
for(var i = 0, j = context.length; i < j; i++) {
ret = ret + options.fn(context[i]);
alert(ret);
}
return ret;
});
This is template:
<template name="mainmenu">
{{#woodoo menuitem}}
<a href="{{url}}">{{title}}</a>
{{/woodoo}}
HTML page is rendering without error, but I can not see urls and I don't have any alert message. Why and how can I fix it ?