vendredi 29 janvier 2016

Parameter passed to Handlebars helper appears as the key instead of the value

I'm making an Ember.js application, and using Handlebars for templates. I've created a handlebars helpers which currently looks like this:

Ember.Handlebars.registerHelper('beautify', function(string) {
    var str= new Ember.Handlebars.SafeString(string.replace(/_/g, ' '));
    return str;
});

And call it like so:

        <td class="small-cell">{{beautify foo}}</td>

But instead of passing the variable "foo" to the helper, handlebars instead passes the string "foo". This is especially odd, because if I try logging the variable with the helper

{{log foo}}

The correct string is displayed.




Aucun commentaire:

Enregistrer un commentaire