Chapsterj
Chapsterj

Reputation: 6625

Using template with underscore methods

I'm trying to use a _.select method to return an array of people that match a certain category. I will then use this later in my script to add them to my span tag. But right now I get an error when I try to run this code. error: illegal character

One other note data is an object I'm passing into the template.

  <script id="product" type="text/template">        
    <p><span>Director</span><span class='director'>
       <% var people= _.select( data.artists, function( item ){
        return item.name == 'painter';
   })%>
  </span>
 </script>

Upvotes: 0

Views: 281

Answers (1)

evilcelery
evilcelery

Reputation: 16139

You need to add the semicolon at the end of the template tag.

  <script id="product" type="text/template">        
    <p><span>Director</span><span class='director'>
       <% var people= _.select( data.artists, function( item ){
        return item.name == 'painter';
   }); %>
  </span>
 </script>

Upvotes: 1

Related Questions