Skip to content

Commit

Permalink
updates for handlebars
Browse files Browse the repository at this point in the history
  • Loading branch information
smohadjer committed Dec 13, 2022
1 parent f0b4c28 commit aa790f1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions bin/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build",
"version": "0.1.0",
"version": "0.1.1",
"description": "A frontend build for HTML Websites",
"repository": {
"type": "git",
Expand Down

0 comments on commit aa790f1

Please sign in to comment.