forked from OpenNHP/opennhp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamazeui.hbs.helper.js
38 lines (35 loc) · 1.11 KB
/
amazeui.hbs.helper.js
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
(function(undefined) {
'use strict';
var registerIfCondHelper = function(hbs) {
hbs.registerHelper('ifCond', function(v1, operator, v2, options) {
switch (operator) {
case '==':
return (v1 == v2) ? options.fn(this) : options.inverse(this);
break;
case '===':
return (v1 === v2) ? options.fn(this) : options.inverse(this);
break;
case '<':
return (v1 < v2) ? options.fn(this) : options.inverse(this);
break;
case '<=':
return (v1 <= v2) ? options.fn(this) : options.inverse(this);
break;
case '>':
return (v1 > v2) ? options.fn(this) : options.inverse(this);
break;
case '>=':
return (v1 >= v2) ? options.fn(this) : options.inverse(this);
break;
default:
return options.inverse(this);
break;
}
return options.inverse(this);
});
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = registerIfCondHelper;
}
this.Handlebars && registerIfCondHelper(this.Handlebars);
}).call(this);