Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails 4:Ember.js不';看不到我的模板?_Ruby On Rails_Ember.js_Handlebars.js - Fatal编程技术网

Ruby on rails Rails 4:Ember.js不';看不到我的模板?

Ruby on rails Rails 4:Ember.js不';看不到我的模板?,ruby-on-rails,ember.js,handlebars.js,Ruby On Rails,Ember.js,Handlebars.js,我正在尝试从templates/about.handlebar渲染一个模板 我在rails视图中设置了插座: %script{ type: 'text/x-handlebars'} <h1> My app</h1> {{ outlet }} ^-- outlet 关于模板是纯html: <h1>This is ABOUT!</h1> 没有关于模板的问题 在编译的js文件中,我可以看到handlebar模板在物理上存在: (funct

我正在尝试从
templates/about.handlebar
渲染一个模板

我在rails视图中设置了插座:

%script{ type: 'text/x-handlebars'}
  <h1> My app</h1>
  {{ outlet }}
  ^-- outlet
关于模板是纯html:

<h1>This is ABOUT!</h1>
没有关于模板的问题

在编译的js文件中,我可以看到handlebar模板在物理上存在:

(function() {
  this.HandlebarsTemplates || (this.HandlebarsTemplates = {});
  this.HandlebarsTemplates["about"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
  this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};



  return "\n<h1>This is ABOUT!</h1>\n\n";
  });
  return this.HandlebarsTemplates["about"];
}).call(this);
(函数(){
this.HandlebarsTemplates | |(this.HandlebarsTemplates={});
this.handlebar.templates[“about”]=handlebar.template(函数(handlebar、depth0、helpers、partials、data){
this.compilerInfo=[4',>=1.0.0'];
helpers=this.merge(helpers,handlebar.helpers);data=data |{};
返回“\n这是关于!\n\n”;
});
返回此。车把模板[“关于”];
}).打电话(这个);
但是我没有看到它被显式地添加到Ember.TEMPLATES中

更新1:检查余烬轨道宝石,我看到把手了吗?文档似乎没有提到这一点


即使我重新命名了模板,它仍然不会显示,而且非常奇怪,因为我在教程或gem文档中没有看到这样的模板名称。

Ember在Ember.templates中查找预编译模板,而不是HandlebarsTemplates。

Handlebars是1.0.12。如果我正确阅读了ember rails gem,ember rails gem将负责将其插入。更新1中的代码意味着,如果您有一个名为
someFile.raw的文件(handlebar | hjs | hbs)
,ember rails将使用
handlebar.compiler
而不是
ember.handlebar.compiler
。Ember.Handlebars.compiler是Handlebars.compiler的扩展,允许在Handlebars模板中使用计算属性、绑定等。很可能这就是你要用的。因此,在中间没有使用<代码>原始<代码>的模板文件。
Object {application: function} 
application: function (context, options) { 
__proto__: Object
(function() {
  this.HandlebarsTemplates || (this.HandlebarsTemplates = {});
  this.HandlebarsTemplates["about"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
  this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};



  return "\n<h1>This is ABOUT!</h1>\n\n";
  });
  return this.HandlebarsTemplates["about"];
}).call(this);