Help! This should't be so difficult, so I assume I'm missing something easy...
I have a variable that's serving as an underscore template. Here's an example (there's more to it, but for simplicity's sake, this is the code that matters):
var template = '<% _.each(favorites, function(value, key) { %> <li><%= key %>: <%= value %></li> <% }); %>';
And what's in 'favorites' you might ask? It's coming from a JSON object that looks something like this (cutting out the other JSON).
"favorites" : [
{ "food" : "shrimp" },
{ "drink" : "none" }
]
Why on earth can I not figure out how to get the key/value pairs to output in the template. All I want to do is print something like this:
<li>food: shrimp</li>
<li>drink: none</li>
What am I doing wrong?