Pluralize or singular string based on a number
Handlebars.registerHelper('pluralize', function(number, singular, plural) {
if (number === 1) {
return singular;
} else {
return (typeof plural === 'string' ? plural : singular + 's');
}
});
Handlebars.registerHelper('pluralCount', function(number, singular, plural) {
return number+' '+Handlebars.helpers.pluralize.apply(this, arguments);
});
Moment.js as a helper method
Handlebars.registerHelper('moment', function(context, block) {
if (window.moment) {
var f = block.hash.format || "MMM Do, YYYY";
return moment(Date(context)).format(f);
}else{
return context; // moment plugin not available. return data as is.
};
});