1

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!

CraigTeegarden
  • 8,173
  • 8
  • 38
  • 43
srisonti
  • 307
  • 4
  • 13

1 Answers1

1

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.

CraigTeegarden
  • 8,173
  • 8
  • 38
  • 43
  • That makes sense. But then if we wanted to have reusable partials in subdirectories inside `app/templates`, how exactly would we do that? – srisonti Feb 24 '15 at 02:59
  • I believe you can just prepend the folder name to the partial `{{partial "foldername/template_name"}}` as long as `template_name.hbs` is in the folder `templates/foldername/` – CraigTeegarden Feb 24 '15 at 03:01
  • That's exactly what we have right now (I tried it both with and without the `_`), and I'm still getting the same error :( – srisonti Feb 24 '15 at 03:12
  • We currently have it as `{{partial 'application/google_analytics'}}` – srisonti Feb 24 '15 at 03:12
  • make sure your template is located at `app/templates/application/google_analytics.hbs` – CraigTeegarden Feb 24 '15 at 03:19
  • Finally figured out what the issue was - apparently in Ember 1.10, you can't use `_` for partials - you need to use `-`. So it should have been `{{partial "application/google-analytics"}}` – srisonti Feb 24 '15 at 05:01