diff --git a/asset-bundles.json b/asset-bundles.json index 012655d..43af0cf 100644 --- a/asset-bundles.json +++ b/asset-bundles.json @@ -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", diff --git a/assets/uf-tweaks/js/handlebars-helpers.js b/assets/uf-tweaks/js/handlebars-helpers.js new file mode 100644 index 0000000..7cf9658 --- /dev/null +++ b/assets/uf-tweaks/js/handlebars-helpers.js @@ -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, ' '); +});