2013-11-25 31 views
0

我有一個觀點,看起來像這樣:Ember.Handlebars.compile返回代碼,而不是把手輸出

App.StarRatingView = Ember.View.extend({ 
    template: function() { 
     return new Ember.Handlebars.compile('test') 
    } 
}) 

據說這是在頁面中插入test,而是它插入compile()函數的定義:

function (context, options) { options = options || {}; var result = templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data); var compilerInfo = container.compilerInfo || [], compilerRevision = compilerInfo[0] || 1, currentRevision = Handlebars.COMPILER_REVISION; if (compilerRevision !== currentRevision) { if (compilerRevision < currentRevision) { var runtimeVersions = Handlebars.REVISION_CHANGES[currentRevision], compilerVersions = Handlebars.REVISION_CHANGES[compilerRevision]; throw "Template was precompiled with an older version of Handlebars than the current runtime. "+ "Please update your precompiler to a newer version ("+runtimeVersions+") or downgrade your runtime to an older version ("+compilerVersions+")."; } else { // Use the embedded version info since the runtime doesn't know about this revision yet throw "Template was precompiled with a newer version of Handlebars than the current runtime. "+ "Please update your runtime to a newer version ("+compilerInfo[1]+")."; } } return result; } 

任何想法爲什麼會發生這種情況?

回答

1

它並不期望的功能。這應該做的伎倆

App.StarRatingView = Ember.View.extend({ 
    template: Ember.Handlebars.compile('test') 
}) 

甚至更​​好:

App.StarRatingView = Ember.View.extend({ 
    templateName: 'test' 
}) 

灰燼現在將呈現使用給定的模板名稱的視圖。