Search code examples
templatesember.jshandlebars.js

"template.buildRenderNodes is not a function" on latest Ember release


HTML and JS (non-minified versions)

index.html

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
    </head>

    <body>
        <!-- <ember> -->
        <script type="text/javascript" src="assets/lib/jquery/jquery.min.js"></script>
        <script type="text/javascript" src="assets/lib/ember.js/ember.min.js"></script>
        <!-- </ember> -->

        <!-- <app> -->
        <script type="text/javascript" src="assets/js/templates.min.js"></script>
        <script type="text/javascript" src="assets/js/app.min.js"></script>
        <!-- </app> -->
    </body>
</html>

app.min.js

window.App = Ember.Application.create();

templates.min.js (the templates are compiled using gulp-ember-templates)

Ember.TEMPLATES["index"] = Ember.Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
  return "";
},"useData":true});

Description

When opening the page in a browser, the following error occurs:

Uncaught TypeError: template.buildRenderNodes is not a function

I'm using the latest version of both Ember and jQuery. When searching for this error I found people having this issue whilst upgrading to Ember 1.13, but I'm using Ember 2.0.0 and didn't call any deprecated method on purpose, actually I'm only using my generated templates (which are empty, because I didn't put any content in yet; see above) and Ember.Application.create().

I also found out that Ember works when including ember-template-compiler.js and keeping the templates uncompiled inside the HTML (using the Handlebars-script-tags).

Question

Is it a bug in Ember or am I missing something? It seems like it should work.


Solution

  • You are using a version of Ember that is using the new Handlebars compatible templating engine HTMLBars. To make sure your templates compile using this new syntax you will need to add the isHTMLBars: true option into the Gulp task for gulp-ember-templates, more formation can be found in the README.