0
votes

I am trying to just render a template from templates/about.handlebars.

I have the outlet setup in rails view:

%script{ type: 'text/x-handlebars'}
  <h1> My app</h1>
  {{ outlet }}
  ^-- outlet

the about route looks like this:

Admin.Router.map ->
  @route 'about', path: '/'

And the about template is plain html:

<h1>This is ABOUT!</h1>

What seems to work:

  • I can see the Ember debug message, that confirms ember is working
  • I have ember chrome extension installed and it can see the application template

But, when I ask for Ember.TEMPLATES, I get:

Object {application: function} 
application: function (context, options) { 
__proto__: Object

and no about template there.

Digging in the compiled js file, I can see the handlebar template is physically there:

(function() {
  this.HandlebarsTemplates || (this.HandlebarsTemplates = {});
  this.HandlebarsTemplates["about"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
  this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};



  return "\n<h1>This is ABOUT!</h1>\n\n";
  });
  return this.HandlebarsTemplates["about"];
}).call(this);

But I don't see it being explicitly added to Ember.TEMPLATES.

Update 1: Inspecting the ember-rails gem, I see that handlebars will match only files that have .raw.(hjs|...), or mustache.(hjs|...) in their names? Documentation doesn't seem to speak about this.

Even if I rename the template it still doesn't show and its supper weird since I haven't seen templates names like that in tutorials, or the gem documentation.

1
That code in Update 1 means that, if you have a file called someFile.raw.(handlebars|hjs|hbs), ember-rails will use Handlebars.compiler instead of Ember.Handlebars.compiler. The Ember.Handlebars.compiler is a extension of Handlebars.compiler that allow the usage of computed properties, bindings, etc in handlebars templates. And probally this is what you will use. So use your templates files without the raw in the middle. - Marcio Junior

1 Answers

0
votes

Ember looks for precompiled templates in Ember.TEMPLATES, not HandlebarsTemplates.