26 lines
502 B
JavaScript
26 lines
502 B
JavaScript
/**
|
|
* This file contains extra helper functions for Handlebars.js.
|
|
*
|
|
* @see http://handlebarsjs.com/#helpers
|
|
*/
|
|
|
|
function ucwords (str) {
|
|
return (str + '').replace(/^([a-z])|\s+([a-z])/g, function ($1) {
|
|
return $1.toUpperCase();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Uppercase words
|
|
*/
|
|
Handlebars.registerHelper('ucwords', function (str) {
|
|
return ucwords(str);
|
|
});
|
|
|
|
/**
|
|
* Split snake case into words
|
|
*/
|
|
Handlebars.registerHelper('splitSnakeCase', function (str) {
|
|
return str.replace(/_/g, ' ');
|
|
});
|