EmberJS - register precompiled steering wheel pattern

In my EmberJS application, I will precompile all the templates for my descriptors, so they are loaded as direct Javascript files.

The problem is that these precompiled templates do not fall into the Ember container, as I thought they were ... I get the following error when I specify a template for my view.

Uncaught Error: assertion failed: You specified the templateName "application" for <MyApp.ApplicationView:ember164>, but it did not exist. 

Here is my view code.

 window.MyApp.ApplicationView = Ember.View.extend({ templateName: 'application' }); 

I went through the execution and saw that these views were missing in the Ember container. Is there anything special I need to do to register precompiled templates with a container? If so, how?

Edit: I compiled templates with the npm pen package.

+6
source share
3 answers

While the npm handbars compiler really compiles them correctly, you still need to register them with Ember so that they can load correctly. You can do one of the following:

  • Manually load them using Ember.TEMPLATES ['sometemplate'] = COMPILED TEMPLATE. It works, but it becomes a bit of a pain.
  • Use a special compiler, for example, npm ember-precompile, which will compile them so that compiled templates are automatically registered in the Ember template container.
0
source

Templates are viewed on Ember.TEMPLATES (it's just a hash with the template name as the key)

So, when your ApplicationView example is executed, it will look for the template in Ember.TEMPLATES['application']

+3
source

If you prefer a solution based on Ruby / Guard, look here: https://gist.github.com/perlun/5286391

Use it as shown in your Guard file:

 guard 'ember_handlebars', :input => 'app/handlebars_templates', :output => 'app/handlebars_compiled', :remove_prefix => 'app/handlebars_templates/' do watch(%r{app/handlebars_templates/(.+\.handlebars)}) end 

`` ``

0
source

All Articles