Add some useful handelbars helpers

This commit is contained in:
bwilliams committed 2023-07-18 13:24:18 +01:00
1 parent 1ce6548849
commit d69a89a761
2 files changed
+35

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
/**
* 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, ' ');
});