I am using backbone as a framework to display a list of all the projects. while rendering the underscore template im running into an 'Underscore.js' error says: SyntaxError: Unexpected token ILLEGAL
Following is my Backbone View:
define([
'jquery',
'underscore',
'backbone',
'collections/projects',
], function($, _, Backbone, ProjectsCollection){
var ProjectListView = Backbone.View.extend({
el: $(".content"),
render: function(){
var self = this;
var projectlist = new ProjectsCollection();
projectlist.fetch({
success: function(projectlist){
var template = _.template($('#userList').html(), {projectlist:projectlist.models})
self.$el.html(template)
}
})
}
});
return ProjectListView;
});
And below is my underscore template that im using to render the details:
Underscore:
<script type = "text/template" id = "userList">
<table>
<thead>
<tr>
<th>name</th>
<th>title</th>
<th>background</th>
</tr>
</thead>
<tbody>
<% _.each(projectlist, function(user){ %>
<tr>
<td><%= user.get('name') %></td>
<td><%= user.get('title') %></td>
<td><%= user.get('background') %></td>
</tr>
<% }) %>
</tbody>
</table>
</script>
HTML to as a container to display the content in:
<div id="container">
<h1>User list</h1>
<div id="menu">Welcome to the project</div>
<div class="content"></div>
</div>
I tried debugging to see where the error might be coming from, at var template = _.template($('#userList').html(), {projectlist:projectlist.models})
step it breaks and runs into the ilegal token error in underscore.js file. I'm wondering the what might the error be. Please any ideass????