I was trying to create a helper that would let me chain helpers together like:
{{ chain "striptags" "<p>asdf</p>" "truncate" 2 }}
But it seems like instead of returning the value after calling a helper in Ember, the last arg has a rendering buffer which gets manipulated by the ember helper. Is there a way to take a normal ember handlebars helper and return the value? My reference code:
/**
* Allows some basic chaining of helpers.
* {{ chain "helper1" arg1 arg2 "helper2" arg2 }}
*/
Ember.Handlebars.helper('chain', function() {
var helperArgs = [];
var helper;
var that = this;
var options = arguments[arguments.length - 1];
$.each(arguments, function(i, arg) {
if(Ember.Handlebars.helpers[arg]){
if(helper){
helperArgs.push(options);
helperArgs = [helper.apply(that, helperArgs)];
}
helper = Ember.Handlebars.helpers[arg];
}else{
helperArgs.push(arg);
}
});
return helper.apply(that, helperArgs);
});