lundi 12 septembre 2016

Ember Piping Feature

Does Ember have a similar feature to Angular2's Piping (http://ift.tt/1XDQhLD)? The closest thing I found were transforms, but that is strictly for the Datastore (DS). I want to convert text "Cat" to "Dog" everywhere, and I don't want to stick if statements everywhere. I can create a utility function to do this, but if there is a specific feature for this then I would like to use that.

Looking for something like this:

let a = "cat";
let b = a | animal; //animal should convert variable a to dog
console.log(a); // cat
console.log(b); // dog

I realize I can do something like this and stick it in the Utilities, but I want to do it the Ember way if there is one:

let animal = function(string) {
  if(a == "cat") {
    return "dog";
  }
}

Is there a built in feature of ember that will do this nicely for me?




Aucun commentaire:

Enregistrer un commentaire