Hello there ! I’m trying to render a HTMLBars template without using the view system. I’d simply like to be able to turn an HTMLBars template into HTML. I don’t really know how to achieve this. To be more specific, i’m using the latest version of ember cli and i’d like to make a jquery select2 component. I’d like to be able to pass a template name as parameter to my component and use this template as a HTML generator for jquery objects (select2 templateSelection option).
I tried the following approach (in my component):
var view = this.createChildView(Ember.View.create({
templateName: templateName,
data: data
}));
var $elem;
Ember.run(function() {
$elem = $('<div>');
view.appendTo($elem);
});
return $elem;
It works, but i get the following error at the end :
Uncaught TypeError: Cannot set property ‘_elementInserted’ of null
I also tried something like this:
var tpl = this.templateForName(mytemplate);
tpl.render(xxx)
But i don’t know how to get the HTMLBars default environment and all the required parameters for the render method.
At the end, i just want to be able to turn a HTMLBars template into HTML with a given data object (and if possible, use my handlebars helpers). I still don’t know if i should use the view system (but these whould be orphan views as the parent is a jquery element) or the template system directly.
Any idea ?
Thx !