1
0
mirror of https://github.com/keeweb/keeweb.git synced 2024-06-21 07:06:39 +02:00
keeweb/app/scripts/hbs-helpers/cmp.js
2019-09-15 14:16:32 +02:00

29 lines
694 B
JavaScript

import Handlebars from 'hbs';
Handlebars.registerHelper('cmp', function(lvalue, rvalue, op, options) {
let cond;
switch (op) {
case '<':
cond = lvalue < rvalue;
break;
case '>':
cond = lvalue > rvalue;
break;
case '>=':
cond = lvalue >= rvalue;
break;
case '<=':
cond = lvalue <= rvalue;
break;
case '===':
case '==':
cond = lvalue === rvalue;
break;
case '!==':
case '!=':
cond = lvalue !== rvalue;
break;
}
return cond ? options.fn(this) : options.inverse(this);
});