|
|
/**
|
|
|
* Created by Gexuhui on 2017/0321.
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
exports.if_cond = function(left, operator, right, options) {
|
|
|
switch (operator) {
|
|
|
case '==':
|
|
|
return (left == right) ? options.fn(this) : options.inverse(this); // eslint-disable-line
|
|
|
case '!=':
|
|
|
return (left != right) ? options.fn(this) : options.inverse(this); // eslint-disable-line
|
|
|
case '===':
|
|
|
return (left === right) ? options.fn(this) : options.inverse(this);
|
|
|
case '<':
|
|
|
return (left < right) ? options.fn(this) : options.inverse(this);
|
|
|
case '<=':
|
|
|
return (left <= right) ? options.fn(this) : options.inverse(this);
|
|
|
case '>':
|
|
|
return (left > right) ? options.fn(this) : options.inverse(this);
|
|
|
case '>=':
|
|
|
return (left >= right) ? options.fn(this) : options.inverse(this);
|
|
|
case '&&':
|
|
|
return (left && right) ? options.fn(this) : options.inverse(this);
|
|
|
case '||':
|
|
|
return (left || right) ? options.fn(this) : options.inverse(this);
|
|
|
default:
|
|
|
return options.inverse(this);
|
|
|
}
|
|
|
};
|
|
|
|
...
|
...
|
|