I’ve taken an entirely different approach using a helper, and running HTMLBars at runtime.
// ember-cli-build.js
app.import('bower_components/ember/ember-template-compiler.js');
import Ember from 'ember';
let count = 0;
export default Ember.Helper.extend({
compute(params/*, hash*/) {
let owner = Ember.getOwner(this);
let uniqueId = `runtime/markup-${count++}`;
let component = Ember.Component.extend({
tagName: '',
layout: Ember.HTMLBars.compile(params[0]),
willDestroy() {
this._super(...arguments);
Ember.run.next(this, () => {
component = null;
});
}
});
owner.register( `component:${uniqueId}`, component );
Ember.run.next(this, () => {
owner.unregister( `component:${uniqueId}` );
});
return uniqueId;
}
});
// invocation
{{#component (runtime-markup markupString)}}
Content
{{/component}}
I totally understand it’s not ideal, but it’s working. My only concern is that I could potentially be called Ember.Component.extend
hundreds of times over the life of the application. With the above method, would there be any potential memory concerns?