Last active
December 17, 2015 05:59
-
-
Save i-Hun/5562503 to your computer and use it in GitHub Desktop.
handlebars helpers style vs. meteor helpers style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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