Skip to content

Commit

Permalink
Merge pull request #131 from qld-gov-au/QOLOE-54-handlebars-IIFE-expo…
Browse files Browse the repository at this point in the history
…rt-for-Squiz

QOLOE-54 adjust handlebars.helpers.js to invoke IIFE function
  • Loading branch information
stvp-qld authored May 20, 2024
2 parents 21f1968 + aa57b93 commit 86d421d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ const buildConfig = {
out: "./assets/css/qld.bootstrap",
},
{
in: "./src/js/handlebars.init.js",
in: "./src/js/handlebars.helpers.js",
out: "./assets/js/handlebars.helpers.bundle",
},
{
in: "./src/js/handlebars.init.js",
out: "./components/handlebars.helpers.bundle",
out: "./components/handlebars.init.bundle",
},
],

Expand Down
7 changes: 7 additions & 0 deletions src/js/handlebars.helpers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/* global Handlebars */

/**
* Registers Handlebars Helper for 'contains', 'ifCond', 'isMultipleOfThree' and 'isEndOfRow'
* @param {module} Handlebars Templating engine
* @returns {void} Result of the helper operation
*/

export default function handlebarsHelpers(Handlebars) {

Handlebars.registerHelper("contains", function (needle, haystack, options) {
needle = Handlebars.escapeExpression(needle);
haystack = Handlebars.escapeExpression(haystack);
Expand Down Expand Up @@ -51,3 +54,7 @@ export default function handlebarsHelpers(Handlebars) {
return ((index + 1) % 3 === 0); // Since index is zero-based, add 1 to check if it's the end of a row.
});
}

if(typeof(Handlebars) !== 'undefined') {
handlebarsHelpers(Handlebars);
}

0 comments on commit 86d421d

Please sign in to comment.