2015-01-29 3 views
8

나는 다음과 같은 오류를 얻을 Handlebars.compile 명령 :Ember.js : HtmlBars 내 응용 프로그램 실행시

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

그것은 코드의이 부분과 관련됩니다 :

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에 추가했는데 같은 오류가 다시 나타납니다.

은 내가 그랬어 :

"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" 

참조 : 다음 ember-template-compilergithub page

누구나 HtmlBars 및 컴파일 명령 경험을 가지고 여기에 npm install --save-dev ember-template-compiler

내 package.json의 devDependencies입니까?

답변

11

클라이언트에서 HTMLBars 템플리트를 컴파일하려하지만, package.jsonember-template-compiler을 추가하면 서버 측 HTMLBars 템플리트 만 사전 컴파일 할 수 있습니다.

클라이언트 측 컴파일을 사용하려면 bower.jsonember-template-compiler을 추가해야합니다. Ember.js 1.10 템플릿 컴파일러는 엠버의 일부이기 때문에 그래서 당신이해야 할 모든 클라이언트 측에서 템플릿을 컴파일하려면,

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

그건 속임수 였어! 그러나 이것이 왜 인터넷에서 문서화되지 않았습니까? 나는 궁극적 인 문서화에 관한 Github 문제를 만든다. – DelphiLynx

+0

해당 문제에 대한 링크를 추가해 주시겠습니까? – Oliver

+0

배경 정보 : http://emberjs.com/blog/2015/02/05/compiling-templates-in-1-10-0.html –

16

,

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

를 (적절한 버전을 사용) 다음 Brocfile.js에 포함 Brocfile에 다음 줄을 추가하는 것입니다 :

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

도움이 완벽하게 작동합니다. – kushdilip

+0

Ember 2.0에서 Brocfile을 찾을 때이 줄을 추가 할 위치 /home/nesh/paint/node_modules/ember-cli-content-security-policy/Brocfile.js 그리고/home/nesh/paint입니다./node_modules/ember-cli-babel/Brocfile.js –

+0

나는이 두 파일에 줄을 추가하려고했지만 같은 문제가있다. –

1

제가보기에는 방금 템플릿 파일을 만들었습니다.

{{view view.itemsView}} 

그런 다음 CarouselView가된다 :

var CarouselView = Ember.View.extend({ 
    templateName: 'views/carousel', 
    elementId: 'carousel', 
    contentBinding: 'content', 
    ... 

클라이언트를 제공하지 않아도이 방법은 예를 들어 귀하의 케이스를 사용하려면, 내가 응용 프로그램/템플릿/뷰/carousel.hbs를 만들 것 템플릿 컴파일러. 더 나은 성능과 더 적은 페이로드로 클라이언트를 다운로드해야합니다.

관련 문제