Ember.js:HtmlBars和Handlebars.compile命令 [英] Ember.js: HtmlBars and the Handlebars.compile command

查看:271
本文介绍了Ember.js:HtmlBars和Handlebars.compile命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 未捕获错误:无法调用`compile`而不加载模板编译器。在调用`compile`之前,请加载`ember-template-compiler.js`。 

与这段代码相关:

  var CarouselView = Ember.View.extend({
template:Ember.Handlebars.compile('{{view view.itemsView}}'),
elementId:'carousel',
contentBinding:'content',
...

ember.js github已经存在与此问题相关的问题: https:// github.com/emberjs/ember.js/issues/10265



但是我添加了 ember-template-compiler 到我的package.json,并得到相同的错误。



我做了:
npm install --save-dev ember-template-compiler



这是我的package.json devDependencies:

 ember-cli:0.1.10,
ember-cli-app-version:0.3.0,
ember-cli- content-security-policy:0.3.0,
ember-cli-dependency-checker:0.0.7,
ember-cli-htmlbars:^ 0.6.0,
ember-cli-ic-ajax:0.1.1,
ember-cli-inject-live-reload :^ 1.3.0,
ember-cli-qunit:0.3.0,
ember-cli-simple-auth:^ 0.7.2,
ember-cli-simple-auth-cookie-store:^ 0.7.2,
ember-cli-simple-auth-oauth2:^ 0.7.2,
ember-cli-uglify:1.0.1,
ember-data:1.0.0-beta.12,
ember-export-application-global .0,
ember-template-compiler:^ 1.8.0,
express:^ 4.8.5,
glob:^ 4.0。 5

参考: ember-template-compiler github页面



任何人都有HtmlBars和编译命令的经验?

解决方案

您正在尝试编译HTMLBars模板客户端,但是在 package.json 中添加 ember-template-compiler 仅启用预编译要启用客户端编译,您应该添加 ember-template-compiler bower.json ,例如(使用适当的版本)

 ember-template-compiler:http://builds.emberjs.com/tags/ v1.10.0-beta.3 / ember-template-compiler.js

然后将其包含在 Brocfile.js

  app.import('bower_components / ember-模板编译/ index.js'); 


I get the following error when running my app:

Uncaught Error: Cannot call `compile` without the template compiler loaded. Please load `ember-template-compiler.js` prior to calling `compile`.

It is related to this piece of code:

var CarouselView = Ember.View.extend({
    template: Ember.Handlebars.compile('{{view view.itemsView}}'),
    elementId: 'carousel',
    contentBinding: 'content',
    ...

There is already an issue related about this problem on ember.js github: https://github.com/emberjs/ember.js/issues/10265

However I added ember-template-compiler to my package.json and got the same error again.

I did: npm install --save-dev ember-template-compiler

Here are my package.json devDependencies:

 "ember-cli": "0.1.10",
 "ember-cli-app-version": "0.3.0",
 "ember-cli-content-security-policy": "0.3.0",
 "ember-cli-dependency-checker": "0.0.7",
 "ember-cli-htmlbars": "^0.6.0",
 "ember-cli-ic-ajax": "0.1.1",
 "ember-cli-inject-live-reload": "^1.3.0",
 "ember-cli-qunit": "0.3.0",
 "ember-cli-simple-auth": "^0.7.2",
 "ember-cli-simple-auth-cookie-store": "^0.7.2",
 "ember-cli-simple-auth-oauth2": "^0.7.2",
 "ember-cli-uglify": "1.0.1",
 "ember-data": "1.0.0-beta.12",
 "ember-export-application-global": "^1.0.0",
 "ember-template-compiler": "^1.8.0",
 "express": "^4.8.5",
 "glob": "^4.0.5"

Reference: the ember-template-compiler github page

Anyone has experience with HtmlBars and the compile command?

解决方案

You are trying to compile HTMLBars template on the client, however adding ember-template-compiler in package.json only enables precompilation of HTMLBars templates server-side.

To enable client-side compilation, you should add ember-template-compiler to the bower.json, e.g. (use appropriate version)

"ember-template-compiler": "http://builds.emberjs.com/tags/v1.10.0-beta.3/ember-template-compiler.js"

and then include it in Brocfile.js,

app.import('bower_components/ember-template-compiler/index.js');

这篇关于Ember.js:HtmlBars和Handlebars.compile命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆