Skip to content

Instantly share code, notes, and snippets.

@i-Hun
Last active December 17, 2015 05:59
Show Gist options
  • Save i-Hun/5562503 to your computer and use it in GitHub Desktop.
Save i-Hun/5562503 to your computer and use it in GitHub Desktop.
handlebars helpers style vs. meteor helpers style
//general Handlebars helper that we can use anywhere
Handlebars.registerHelper("formatDate", function(date) {
return new Handlebars.SafeString(
moment(date).format('LL')
);
});
//Плюрализация. Работает для всех шаблонов.
Handlebars.registerHelper('pluralize', function(n, thing) {
// fairly stupid pluralizer
if (n === 1) {
return '1 ' + thing;
} else {
return n + ' ' + thing + 's';
}
});
{{pluralize votes "Vote"}}
// meteor helpers style
Template.post.helpers({
formatDate: function (date) {
return moment(date).format('LL');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment