mirror of
https://github.com/keeweb/keeweb.git
synced 2024-06-27 07:45:08 +02:00
29 lines
699 B
JavaScript
29 lines
699 B
JavaScript
const Handlebars = require('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);
|
|
});
|