Reputation: 6625
I keep getting an error with this. I keep getting a syntax error:
syntax error var _p=[],print=function(){_p.push.a... ');}return __p.join('');
<script id="product" type="text/template">
<p><span>items</span><span class='items'><%= _.each(info.items, function(books) { %>
<%= books.name + ", " %>
<% }); %></span></p>
</script>
Anyone know why this error is happening. I have looked at some other people using this style and it seems correct but maybe I'm missing a symbol?
Note: Fixed the issue.
My code had a =
sign in the wrong place.
<%= _.each(info.items, function(books) { %>
should be:
<% _.each(info.items, function(books) { %>
Not sure why you need the =
for some areas and not for others. Maybe someone can explain.
example in this area of the code I need to use a =
sign :
<%= books.name + ", " %>
Upvotes: 1
Views: 2127
Reputation: 16139
With the default settings, when you do <%= variable %>
it just prints out the value of variable
.
To evaluate (i.e. run a piece of Javascript code) you do <% alert('something') %>
Upvotes: 3