Javascript Backbone.js-从视图渲染阵列,而不在模板中循环

Javascript Backbone.js-从视图渲染阵列,而不在模板中循环,javascript,ruby-on-rails,backbone.js,backbone-views,Javascript,Ruby On Rails,Backbone.js,Backbone Views,我正在使用主干加载页面的所有帖子。以及在点击“获取所有评论”链接时为帖子加载评论。我从一个Ajax调用中得到了所有的评论 Social.Views.StreamsIndex = Backbone.View.extend({ comment_template: JST['streams/comment'], comment_displayall: function(data, post_id) { this.$("#comments").html(this.comm

我正在使用主干加载页面的所有帖子。以及在点击“获取所有评论”链接时为帖子加载评论。我从一个Ajax调用中得到了所有的评论

Social.Views.StreamsIndex = Backbone.View.extend({

    comment_template: JST['streams/comment'],

    comment_displayall: function(data, post_id) {
      this.$("#comments").html(this.comment_template({
        comment: data // Here data is array
      }));
    }
});
我有一个comment.jst.ejs文件,它现在有一个循环,但我必须把它放到视图中

  <% _.each(comment.comments,function(comment){ %> // I want to get rid of this Line
 <div class="stream_comment">
   <div class="stream_commentphoto">
    <a><img src="<%= comment.actor.thumbnail.url %>"></a>
   </div>
   <div class="stream_comm-content">
    <a href="#"><h5><%= comment.actor.displayName %></h5> </a>
    <p><%= comment.content %></p>
   </div>
 </div>
<%}%>
//我想去掉这一行


如何通过在视图中添加循环来消除注释模板中的循环?

可能类似于以下内容:

comment_displayall: function(data, post_id) {

    //clear any existing comments
    var $comments = this.$("#comments").empty();

    //render each comment separately and append to the view
    _.each(data.comments, function(comment) {
        $comments.append(this.comment_template({comment:comment});      
    }, this);
}
只需删除模板的循环构造(第一行和最后一行)

/未测试的代码示例