我们目前正在使用ember-cli 1.10.0
,ember-cli-htmlbars 0.7.4
开箱即用ember-cli
。
我们的app目录是application.hbs
开箱即用的设置。 app > templates
中有一个app > templates > application
文件,我们添加了一个目录application.hbs
,其中我们为_google_analytics.hbs
加载了所有部分内容。其中一个部分是Uncaught Error: Assertion Failed: Unable to find partial with name "application/google_analytics"
。
我们一直遇到错误Ember.TEMPLATES
,并且_google_analytics.hbs
在控制台中为空。当我们故意弄乱ember server
时,package.json
会抛出错误而无法编译,因此所有模板都在编译器中运行,但Ember无法找到它们。
这是我们的{
"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"
}
}
文件:
{
"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"
}
}
这是我们的bower.json文件:
/* 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();
这是我们的Brocfile:
environments.js
我们甚至与html-bars
混淆并启用EmberENV: {
FEATURES: {
'ember-htmlbars': true
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
}
},
功能,如下所示:
{{1}}
但这并不奏效,因为我们没有使用金丝雀的Ember版本。我们还没有在其他任何地方看到这个问题,所以看起来它是一个相当明显的东西,我们已经失踪了。任何帮助将不胜感激!
答案 0 :(得分:1)
删除前导下划线(_
)。
根据Ember-CLI Docs,google_analytics.hbs
文件夹中的正确模板文件名为app/templates/
。
{{partial "google_analytics"}}
会引用templates/google_analytics.hbs
Ember.TEMPLATES
为空,因为CLI使用所有内容的模块,包括模板。模板存储为前缀为application_name/templates/
的模块。由于这与常规约定不同,CLI使用自定义解析程序,让Ember在此位置查找模板。如果您检查源代码,您将发现所有模板都将遵循此约定。