0
votes

I have an event where I need to insert a template into space outside of the app. With Ember-CLI we have all these wonderfully pre-compiled templates, so I'm trying to figure out how I can use one.

(Ember-CLI 0.0.42, Ember 1.7.0)

I found I can get the pre-compiled template function like this:

import TheTemplate from 'app/templates/the-template';

However, if I call it as documented on the Handlebars website, I get an error.

var context = { button: "OK" };
var str = TheTemplate(context);

Uncaught TypeError: Cannot read property 'push' of undefined

So what is the proper way to use these templates?

1
Handlebars.template("the-template") also gets the template.Nathan

1 Answers

0
votes

This question, asked in a different way, may have been answered already:

Compile Ember template string and running it programmatically, without an Ember application?

Using both a template and view, something like this would seem to work from within another view:

externalView = this.get("container").lookup("view:the-template");
externalView.setProperties({ button: "OK" });
externalView.appendTo($("#here"));

...and then remember to destroy() or destroyElement() later on.