mardi 5 novembre 2019

I am gettting the error: Compile Error: ifCond is not a helper when I am trying to write a helper function in Ember

I have a helper function (ifCond) in ember.js as below

 export default () => {
    Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) {
        alert("hi");
        if (params[3]) {  //handle case insensitive conditions if 4 param is passed.
            params[0] = params[0].toLowerCase();
            params[2] = params[2].toLowerCase();
        }
    let v1 = params[0];
    let operator = params[1];
    let v2 = params[2];

    switch (operator) {
        case '==':
            return (v1 == v2);
        case '!=':
            return (v1 != v2);
        case '===':
            return (v1 === v2);
        case '<':
            return (v1 < v2);
        case '<=':
            return (v1 <= v2);
        case '>':
            return (v1 > v2);
        case '>=':
            return (v1 >= v2);
        case '&&':
            return !!(v1 && v2);
        case '||':
            return !!(v1 || v2);
        default:
            return false;
    }
    });
}

when I am trying to access this function in my hbs file as below

                                                    
                                                    
                                                    <br />
                                                    

I am getting error as below:

Any help please - thanks in advance




Aucun commentaire:

Enregistrer un commentaire