2 Handlebars.registerHelper('mkws-json', function(obj) {
7 Handlebars.registerHelper('mkws-paragraphs', function(obj) {
9 for (var i = 0; i < obj.length; i++) {
10 acc.push('<p>', obj[i], '</p>');
16 Handlebars.registerHelper('mkws-translate', function(s) {
21 // We need {{mkws-attr '@name'}} because Handlebars can't parse {{@name}}
22 Handlebars.registerHelper('mkws-attr', function(attrName) {
23 return this[attrName];
28 * Use as follows: {{#mkws-if-any NAME1 having="NAME2"}}
29 * Applicable when NAME1 is the name of an array
30 * The guarded code runs only if at least one element of the NAME1
31 * array has a subelement called NAME2.
33 Handlebars.registerHelper('mkws-if-any', function(items, options) {
34 var having = options.hash.having;
35 for (var i in items) {
37 if (!having || item[having]) {
38 return options.fn(this);
45 Handlebars.registerHelper('mkws-first', function(items, options) {
46 var having = options.hash.having;
47 for (var i in items) {
49 if (!having || item[having]) {
50 return options.fn(item);
57 Handlebars.registerHelper('mkws-commaList', function(items, options) {
60 for (var i in items) {
61 if (i > 0) out += ", ";
62 out += options.fn(items[i])
69 Handlebars.registerHelper('mkws-index1', function(obj) {
70 return obj.data.index + 1;