2012-09-13 27 views
1

我正在关注Rails的Ryan Bates backbone.js教程。他使用jst.eco模板。不过,我正在使用jst.ejs文件。Backbone:在jst.ejs文件中呈现动态内容

他认为造成他要插入到模板中的一些内容,即“项放在这里”

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

,它会在<%= @entries %>模板

<h1>App Name</h1> 

<%= @entries %> 

我插入米这样做与index.jst.ejs文件,它不工作。

首先。有谁知道我应该在模板中使用什么标签来呈现动态内容?

其次,它仍然是正确的,我没有使用CoffeeScript的

回答

0

不需要@或'做entries: "Entries go here"模板内()括号,如

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

注这'在模板的'条目'前面。

查看/条目/索引

render: function(){ 

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

     entries: "Entries go here" 

    })); 
    return this; 
    } 

模板/条目/ index.jst.ejs

<%= entries %>