3 Handlebars.registerHelper('mkws-json', function(obj) {
8 // This is intended to handle paragraphs from Wikipedia, hence the
9 // rather hacky code to remove numbered references.
11 Handlebars.registerHelper('mkws-paragraphs', function(obj) {
13 for (var i = 0; i < obj.length; i++) {
14 acc.push('<p>', obj[i].replace(/\[[0-9,]+\]/g, ''), '</p>');
20 Handlebars.registerHelper('mkws-translate', function(s) {
25 // We need {{mkws-attr '@name'}} because Handlebars can't parse {{@name}}
26 Handlebars.registerHelper('mkws-attr', function(attrName) {
27 return this[attrName];
32 * Use as follows: {{#mkws-if-any NAME1 having="NAME2"}}
33 * Applicable when NAME1 is the name of an array
34 * The guarded code runs only if at least one element of the NAME1
35 * array has a subelement called NAME2.
37 Handlebars.registerHelper('mkws-if-any', function(items, options) {
38 var having = options.hash.having;
39 for (var i in items) {
41 if (!having || item[having]) {
42 return options.fn(this);
49 Handlebars.registerHelper('mkws-first', function(items, options) {
50 var having = options.hash.having;
51 for (var i in items) {
53 if (!having || item[having]) {
54 return options.fn(item);
61 Handlebars.registerHelper('mkws-commaList', function(items, options) {
64 for (var i in items) {
65 if (i > 0) out += ", ";
66 out += options.fn(items[i])
73 Handlebars.registerHelper('mkws-index1', function(obj) {
74 return obj.data.index + 1;