mercredi 1 avril 2015

How to compile inline HTMLBars templates?

I have an inline template (template in JavaScript) that I used to compile like so (where temp is a Handlebars string):



var template = Handlebars.compile(temp);
template({model: results}); // Gets the HTML


I'm trying to use HTMLBars instead, but can't quite figure it out. I did the following:



var template = Ember.HTMLBars.compile(temp);
template({model: results}); // Throws an error that template isn't a function


How do I go about getting the HTML back from the HTMLBars template. I also tried:



var template = Ember.HTMLBars.compile(temp);
Ember.HtmlBars.template(template, {model: results});


Which doesn't error, but also doesn't use the model when rendering the HTML. I think I'm close, but can't quite figure out how to inject the model.





Aucun commentaire:

Enregistrer un commentaire