/*globals Handlebars, moment */

(function() {
  // Get the current url
  Handlebars.registerHelper('windowLocation', function(place_id) {
    return window.location;
  });

  // Change new lines to <br> tags. This one is better than Swag.
  Handlebars.registerHelper('nlToBr', function(str) {
    if (str) {
      str = Handlebars.Utils.escapeExpression(str);
      return new Handlebars.SafeString(str.replace(/\r?\n|\r/g, '<br>'));
    } else {
      return str;
    }
  });

  // Date and time ------------------------------------------------------------
  Handlebars.registerHelper('formatDateTime', function(datetime, format) {
    if (datetime) {
      return moment(datetime).format(format);
    }
    return '';
  });

  Handlebars.registerHelper('fromNow', function(datetime) {
    if (datetime) {
      return moment(datetime).fromNow();
    }
    return '';
  });

}());
@@ -870,13 +870,448 @@
 %0A  %7D);%0A%0A
+  // Iteration ----------------------------------------------------------------%0A  Handlebars.registerHelper('times', function(n, options) %7B%0A    var accum = '', i;%0A    for(i = 0; i %3C n; ++i)%7B%0A      accum += options.fn(i);%0A    %7D%0A    return accum;%0A  %7D);%0A%0A  Handlebars.registerHelper('range', function(from, to, options) %7B%0A    var accum = '', i;%0A    for(i = from; i %3C to; i++)%7B%0A      accum += options.fn(i);%0A    %7D%0A    return accum;%0A  %7D);%0A%0A
 %7D());

Add times and range.