"意外的令牌<"在下划线模板中

时间:2016-03-04 06:52:08

标签: javascript node.js backbone.js underscore.js underscore.js-templating

我遇到了以下错误"意外令牌<"虽然我使用下划线模板在backbone.js的app构建中运行以下代码。 这是代码:

objects

这是我的html模板:

var data = [{'date':'03 Mar', 'users':5, 'not_ended_sessions':25}]
var rowtemplate = _.template(this.template, {'data': data });
$(this.el).html(html);

我看了谷歌上的各种博客,并根据建议进行了更改,但仍然得到同样的错误。

有人可以调查一下吗? 感谢。

1 个答案:

答案 0 :(得分:2)

代码中存在语法错误,最后一个td

<section class="clearfix"> 
  <table> 
    <thead class="title">
      <tr> 
        <th class='date'>Date</th>
        <th>Users</th> 
        <th>Not Ended Session(s)</th> 
       </tr> 
     </thead> 
     <tbody> 
     <% _.each(data, function(el){ %> 
       <tr> 
         <td ><%= el.date %></td> 
         <td ><%= el.users %></td> 
         <td ><%= el.not_ended_sessions %></td> 
       </tr> 
     <% }); %> 
     </tbody> 
   </table> 
   <p class="Total Session(s)">0</p> 
</section>