index.js
1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* Created by TaoHuang on 2016/10/26.
*/
'use strict';
exports.if_cond = (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);
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);
}
};
exports.escapeType = (value) => {
let strs = value.split('');
if (strs.length === 2) {
strs[2] = strs[1];
strs[1] = ' ';
}
return strs.join('');
};