Add some useful handelbars helpers
This commit is contained in:
@@ -1,5 +1,15 @@
|
||||
{
|
||||
"bundle": {
|
||||
"js/admin": {
|
||||
"scripts": [
|
||||
"uf-tweaks/js/handlebars-helpers.js"
|
||||
],
|
||||
"options": {
|
||||
"sprinkle": {
|
||||
"onCollision": "merge"
|
||||
}
|
||||
}
|
||||
},
|
||||
"js/pages/group": {
|
||||
"scripts": [
|
||||
"uf-tweaks/js/pages/group.js",
|
||||
|
||||
25
assets/uf-tweaks/js/handlebars-helpers.js
Normal file
25
assets/uf-tweaks/js/handlebars-helpers.js
Normal 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, ' ');
|
||||
});
|
||||
Reference in New Issue
Block a user