Handlebars ucword helper.

This commit is contained in:
opi 2014-02-18 23:26:11 +01:00
parent 860ba5a253
commit 4134d3c48a

View file

@ -7,6 +7,11 @@ app = Sammy('#main', function (sam) {
// Plugins // Plugins
sam.use('Handlebars', 'ms'); sam.use('Handlebars', 'ms');
Handlebars.registerHelper('ucwords', function(str) {
return (str + '').replace(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g, function ($1) {
return $1.toUpperCase();
});
});
Handlebars.registerHelper('humanSize', function(bytes) { Handlebars.registerHelper('humanSize', function(bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return 'n/a'; if (bytes == 0) return 'n/a';