当我正在努力让 ember 运行时,我现在无法让我的车把模板通过资产管道加载。我正在使用 handlebars_assets gem,当我点击服务器时,我得到了下面的内容,我验证了路径是正确的,但不确定如何解决这个问题。当我需要 handlebars.runtime 时:
couldn't find file 'handlebars.runtime'
(in /Users/tspore/Rails/Active/tombfinder/app/assets/javascripts/app/ember_app.js:1)
Cache read: sprockets/6f42a4ba0f2b80167ce50f9f306427fa
Compiled app/ember_app.js (5ms) (pid 9791)
Cache read: sprockets/764613d8100bb6d8e6072701f79183c1
Completed 500 Internal Server Error in 141ms
ActionView::Template::Error (can't convert nil into String
(in /Users/tspore/Rails/Active/tombfinder/app/assets/javascripts/app/templates/records/index.hbs)):
26: <% end %>
27:
28:
29: <%= javascript_include_tag 'app/ember_app' %>
30: </head>
31: <body class="<%= @class %>">
32: <div id="center">
app/views/layouts/js.html.erb:29:in `_app_views_layouts_js_html_erb__854441834177334479_70351597254240'
app/controllers/js/js_controller.rb:3:in `index'
Rendered /Users/tspore/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.1.10/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.9ms)
Rendered /Users/tspore/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.1.10/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.6ms)
Rendered /Users/tspore/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.1.10/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (3.0ms)
编辑:在使用 Github 版本并从 :assets 中删除 gem 之后 - 它似乎有效。但是现在我收到了这个错误-
Uncaught ReferenceError: HandlebarsTemplates is not defined records_view.js:4 Uncaught Error: assertion failed: Unable to find view at path 'App.listRecordsView'
我的应用程序看起来像这样 -
App.listRecordsView = Ember.View.extend({
templateName: HandlebarsTemplates['records/index'](context)
});
使用 ember-rails gem,我得到了要编译的 gem,所以现在我有一个名为 layout.js 的脚本,它看起来像这样:
Ember.TEMPLATES["app/templates/controller/layout"] = Ember.Handlebars.template(function anonymous(Handlebars, depth0, helpers, partials, data) { helpers = helpers || Ember.Handlebars.helpers; data = data || {};
var buffer = '', stack1, hashTypes, escapeExpression=this.escapeExpression;
data.buffer.push("<h1>from template</h1>\n");
stack1 = {};
hashTypes = {};
stack1 = helpers._triageMustache.call(depth0, "outlet", {hash:stack1,contexts:[depth0],types:["ID"],hashTypes:hashTypes,data:data});
data.buffer.push(escapeExpression(stack1) + "\n");
return buffer;
});
如何在 Ember 应用程序中调用此模板?它没有名称空间可以说: templateName: 'layout'