Search code examples
javascriptember.jsember-cli

Ember.TEMPLATES is empty (ember-cli-htmlbars)


We're currently using ember-cli 1.10.0, which comes out of the box with ember-cli-htmlbars 0.7.4.

Our app directory is what ember-cli sets up out of the box. There's an application.hbs file in app > templates, and we added a directory app > templates > application where we have all of the partials to be loaded for application.hbs. One of the partials is _google_analytics.hbs.

We keep running into the error Uncaught Error: Assertion Failed: Unable to find partial with name "application/google_analytics", and Ember.TEMPLATES is empty in the console. When we intentionally mess up _google_analytics.hbs, ember server throws an error and fails to compile, so all of the templates are running through the compiler, but Ember isn't able to find them.

Here's our package.json file:

{
  "name": "app",
  "version": "0.0.0",
  "description": "Small description for app goes here",
  "private": true,
  "directories": {
    "doc": "doc",
    "test": "tests"
  },
  "scripts": {
    "start": "ember server",
    "build": "ember build",
    "test": "ember test"
  },
  "repository": "",
  "engines": {
    "node": ">= 0.10.0"
  },
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "broccoli-asset-rev": "^2.0.0",
    "ember-cli": "0.2.0-beta.1",
    "ember-cli-app-version": "0.3.1",
    "ember-cli-babel": "^4.0.0",
    "ember-cli-dependency-checker": "0.0.7",
    "ember-cli-dotenv": "^0.4.0",
    "ember-cli-htmlbars": "0.7.4",
    "ember-cli-ic-ajax": "0.1.1",
    "ember-cli-inject-live-reload": "^1.3.0",
    "ember-cli-qunit": "0.3.8",
    "ember-cli-simple-auth": "^0.7.3",
    "ember-cli-uglify": "1.0.1",
    "ember-data": "1.0.0-beta.15",
    "ember-export-application-global": "^1.0.2",
    "express": "^4.8.5",
    "glob": "^4.0.5"
  }
}

Here's our bower.json file:

{
  "name": "app",
  "dependencies": {
    "jquery": "^1.11.1",
    "ember": "1.10.0",
    "ember-data": "1.0.0-beta.15",
    "ember-resolver": "~0.1.11",
    "loader.js": "ember-cli/loader.js#1.0.1",
    "ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
    "ember-cli-test-loader": "ember-cli-test-loader#0.1.3",
    "ember-load-initializers": "ember-cli/ember-load-initializers#0.0.2",
    "ember-qunit": "0.2.8",
    "ember-qunit-notifications": "0.0.7",
    "qunit": "~1.17.1",
    "ember-simple-auth": "~0.7.3",
    "bootstrap": "~3.3.2",
    "normalize.css": "~3.0.2"
  },
  "devDependencies": {
    "dynatable": "~0.3.1",
    "bootstrap-datepicker": "~1.3.1",
    "hopscotch": "~0.2.3",
    "jquery-dateFormat": "~1.0.2"
  }
}

And here's our Brocfile:

/* global require, module */

var EmberApp = require('ember-cli/lib/broccoli/ember-app');

var app = new EmberApp({
  dotEnv: {
    clientAllowedKeys: ['SOME_KEY', 'SOME_OTHER_KEY']
  }
});

module.exports = app.toTree();

We even messed with environments.js and turned on the html-bars feature like so:

EmberENV: {
  FEATURES: {
    'ember-htmlbars': true
    // Here you can enable experimental features on an ember canary build
    // e.g. 'with-controller': true
  }
},

But that didn't work because we aren't using a canary build of Ember. We haven't seen this issue documented anywhere else, so it looks like it's something fairly obvious that we're missing. Any help would be greatly appreciated!


Solution

  • Remove the leading underscore (_).

    According to the Ember-CLI Docs, the correct template filename would be google_analytics.hbs in the app/templates/ folder.

    {{partial "google_analytics"}}
    

    would refer to templates/google_analytics.hbs

    Ember.TEMPLATES is empty because the CLI uses modules for everything, including the templates. The templates are stored as modules prefixed with application_name/templates/. Since this is different than the normal convention, CLI uses a custom resolver that lets Ember find template at this location. If you examine your source code you will find all of your templates will be in modules following this convention.