From cd021b5299369c84877d1af2bb5fe1bb3975d2e1 Mon Sep 17 00:00:00 2001 From: Aetherinox Date: Sun, 21 Apr 2024 03:37:07 -0700 Subject: [PATCH] refactor: add hbs-helpers ifgtr, iflss --- app/scripts/hbs-helpers/ifgtr.js | 9 +++++++++ app/scripts/hbs-helpers/iflss.js | 9 +++++++++ app/scripts/hbs-helpers/index.js | 2 ++ 3 files changed, 20 insertions(+) create mode 100644 app/scripts/hbs-helpers/ifgtr.js create mode 100644 app/scripts/hbs-helpers/iflss.js diff --git a/app/scripts/hbs-helpers/ifgtr.js b/app/scripts/hbs-helpers/ifgtr.js new file mode 100644 index 00000000..b360bf2f --- /dev/null +++ b/app/scripts/hbs-helpers/ifgtr.js @@ -0,0 +1,9 @@ +import Handlebars from 'hbs'; + +Handlebars.registerHelper('ifgtr', function (lvalue, rvalue, options) { + return lvalue > rvalue ? options.fn(this) : options.inverse(this); +}); + +Handlebars.registerHelper('ifgeq', function (lvalue, rvalue, options) { + return lvalue >= rvalue ? options.fn(this) : options.inverse(this); +}); diff --git a/app/scripts/hbs-helpers/iflss.js b/app/scripts/hbs-helpers/iflss.js new file mode 100644 index 00000000..4a426536 --- /dev/null +++ b/app/scripts/hbs-helpers/iflss.js @@ -0,0 +1,9 @@ +import Handlebars from 'hbs'; + +Handlebars.registerHelper('iflss', function (lvalue, rvalue, options) { + return lvalue < rvalue ? options.fn(this) : options.inverse(this); +}); + +Handlebars.registerHelper('ifleq', function (lvalue, rvalue, options) { + return lvalue <= rvalue ? options.fn(this) : options.inverse(this); +}); diff --git a/app/scripts/hbs-helpers/index.js b/app/scripts/hbs-helpers/index.js index a7b23692..98136e50 100644 --- a/app/scripts/hbs-helpers/index.js +++ b/app/scripts/hbs-helpers/index.js @@ -2,5 +2,7 @@ import 'hbs-helpers/add'; import 'hbs-helpers/cmp'; import 'hbs-helpers/ifeq'; import 'hbs-helpers/ifneq'; +import 'hbs-helpers/ifgtr'; +import 'hbs-helpers/iflss'; import 'hbs-helpers/ifemptyoreq'; import 'hbs-helpers/res';