I have a file ifCond.js, in which I have bunch of helper functions, but I am concerned with mainly two functions log (which logs in values in hbs file) and IMS.ConditionHelper, I am not able to use IMS.ConditionHelper why, I want to use this function for that purpose, how can I do it - any help please? Here is my ifCond.js code:
export default () => {
var log = function (data) {
console.log(data);
}
var log = Ember.assign(log, {
print: function (style, message) {
var template = "";
style.forEach(function (item) {
if (typeof item == 'object') {
for (var prop in item) {
template += prop + ":" + item[prop] + ";";
}
} else {
var style = log.styles[item];
if (style)
for (var prop in style) {
template += prop + ":" + style[prop] + ";";
}
}
})
},
styles: {
title: {
'font-size': '30px',
},
italic: {
'font-style': 'italic'
},
bold: {
'font-weight': 'bold'
},
underline: {
'text-decoration': 'underline'
},
success: {
'color': '#23aa15'
},
error: {
'color': '#ee3619'
},
attention: {
'color': '#ee339e'
}
}
});
IMS.ConditionHelper = Ember.Helper.extend({
compute: function (args) {
var v1 = args[0],
operator = args[1],
v2 = args[2];
if (v1 === undefined || v2 === undefined) {
console.warn("Condition BoundHelper received undefined value");
return false;
}
switch (operator) {
case '!=':
return (v1 != v2) ? true : false;
case '==':
return (v1 == v2) ? true : false;
case '===':
return (v1 === v2) ? true : false;
case '<':
return (v1 < v2) ? true : false;
case '<=':
return (v1 <= v2) ? true : false;
case '>':
return (v1 > v2) ? true : false;
case '>=':
return (v1 >= v2) ? true : false;
case '&&':
return (v1 && v2) ? true : false;
case '||':
return (v1 || v2) ? true : false;
default:
return false;
}
}
})
}
Any help, I want a conditional operator - any help would be very very helpful - thanks in advance. I am not sure if I am using Ember-cli or Ember webpack but application is working except this ConditionHelper function being called in the Handlebar file - any help would be greatly helpful - thanks in advance
Aucun commentaire:
Enregistrer un commentaire