javascript - Underscore template display array of objects via _.each -


i'm having trouble printing out simple each comment loop _.template.

<% _.each([comments], function(i) { %>  <p><%= %></p> <% }); %> 

prints [object object]

<% _.each([comments], function(i) { %>  <p><%= json.stringify(i) %></p> <% }); %> 

prints:

[{"comment":"mauris quis leo @ diam molestie sagittis.","id":263,"observation_id":25}] 

what i've tried far:

<% _.each([comments], function(i) { %>  <p><%= i.comment %></p> <% }); %> 

blank

<% _.each([comments], function(i) { %>  <p><%= i.get('comment') %></p> <% }); %> 

uncaught typeerror: object [object array] has no method 'get'

<% _.each([comments], function(i) { %>  <p><%= comment %></p> <% }); %> 

blank

assuming comments array on model:

<% _.each(comments, function(comment) { %>     <p><%= comment.comment %></p>  <% }); %> 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -