X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=tools%2Fhtdocs%2Fmkws.js;h=124b3115fb9723bcf7227d31e86b8337e09fd45a;hb=588dc0fed2bd1f9240418e05a87514796679223a;hp=8e282a8d3f2271dab6f393d35426af018e198c91;hpb=b02972410ce4e86179e43f92f66a9eb4a6d3e909;p=mkws-moved-to-github.git diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 8e282a8..124b311 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -118,8 +118,21 @@ Handlebars.registerHelper('json', function(obj) { }); +// We need {{attr name}} because Handlebars can't parse {{@@name}} +Handlebars.registerHelper('attr', function(attrName) { + return this['@' + attrName]; +}); + + Handlebars.registerHelper('first', function(items, options) { - return options.fn(items[0]); + var having = options.hash.having; + for (var i in items) { + var item = items[i] + if (!having || item[having]) { + return options.fn(item); + } + } + return ""; });