1

我正在关注 Rails 的 Ryan Bates 主干.js 教程。他使用 jst.eco 模板。但是,我使用的是 jst.ejs 文件。

他的视图创建了一些他想插入到模板中的内容,即“Entries go here”

$(this.el).html(this.template(entries: "Entries go here"));
 return this;

它将被插入 <%= @entries %>到模板中

<h1>App Name</h1>

<%= @entries %>

我正在使用 index.jst.ejs 文件执行此操作,但它不起作用。

第一的。有谁知道我应该在模板中使用哪些标签来呈现动态内容?

entries: "Entries go here"其次,在 template() 括号内做是否仍然正确,如

$(this.el).html(this.template({entries: "Entries go here"}));

注意,我没有使用咖啡脚本

4

1 回答 1

0

模板中的“条目”前面不需要@ 或“this”。

视图/条目/索引

 render: function(){

    $(this.el).html(this.template({

        entries: "Entries go here"

    }));
    return this;
  }

模板/条目/index.jst.ejs

<%= entries %>
于 2012-09-13T04:29:26.320 回答