diff --git a/app.js b/app.js index aa12997..b86f79c 100644 --- a/app.js +++ b/app.js @@ -12,6 +12,7 @@ const serveStatic = require('serve-static'); // Import user defined modules const DatabaseConnectionPool = require('./lib/DatabaseConnectionPool'); +const hbsHelpers = require('./lib/handlebarsHelpers.js'); const importJSON = require('./lib/importJSON'); @@ -53,7 +54,8 @@ async function main() { app.engine( 'hbs', engine({ - extname: '.hbs' + extname: '.hbs', + helpers: hbsHelpers }) ); app.set('view engine', 'hbs'); diff --git a/lib/handlebarsHelpers.js b/lib/handlebarsHelpers.js new file mode 100644 index 0000000..88bd8f2 --- /dev/null +++ b/lib/handlebarsHelpers.js @@ -0,0 +1,6 @@ +const helpers = {}; + +helpers.eq = (arg1, arg2, options) => + arg1 == arg2 ? options.fn(this) : options.inverse(this); + +module.exports = helpers;