From aa790f183a0345bc982ec206272ba5a875dbcbf8 Mon Sep 17 00:00:00 2001 From: Saeid Mohadjer Date: Tue, 13 Dec 2022 16:34:16 +0100 Subject: [PATCH] updates for handlebars --- bin/utils.js | 21 ++++++++++++++------- package.json | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/bin/utils.js b/bin/utils.js index 0cf28bf..c0841fe 100644 --- a/bin/utils.js +++ b/bin/utils.js @@ -19,13 +19,20 @@ module.exports = { myRecursiveFunction(dir, callback); }, registerHandlebarsHelpers: () => { - handlebars.registerHelper('ifeq', function (a, b, options) { - if (a == b) { return options.fn(this); } - return options.inverse(this); - }); - handlebars.registerHelper('ifnoteq', function (a, b, options) { - if (a != b) { return options.fn(this); } - return options.inverse(this); + /* taken from: https://stackoverflow.com/a/31632215/884177 */ + handlebars.registerHelper({ + eq: (v1, v2) => v1 === v2, + ne: (v1, v2) => v1 !== v2, + lt: (v1, v2) => v1 < v2, + gt: (v1, v2) => v1 > v2, + lte: (v1, v2) => v1 <= v2, + gte: (v1, v2) => v1 >= v2, + and() { + return Array.prototype.every.call(arguments, Boolean); + }, + or() { + return Array.prototype.slice.call(arguments, 0, -1).some(Boolean); + } }); } } diff --git a/package.json b/package.json index de58e20..cae7cc6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "build", - "version": "0.1.0", + "version": "0.1.1", "description": "A frontend build for HTML Websites", "repository": { "type": "git",