RsD0p9BK
3/9/2017 - 4:12 AM

underscore__template.html

<!-- how to print array in underscore.js template -->

<script type='text/template' id="bunny-template">
  <div> 
     <h5><%= name %></h5>
     <ul>
       <% for(var tag in tags) { %>
           <li><%= tags[tag] %></li>
       <% } %>
     </ul>
  </div>
</script>

<!-- http://stackoverflow.com/questions/8648629/how-to-print-array-in-underscore-js-template -->

<script>
  render: function() {
     this.$el.html( this.template( items : this.model.toJSON()));
     return this;
  }
</script>

<ul>
   <li><a href="#">${name}</a>
      <ul> {each items}
          <li><a href="#">${name}</a></li>
      </ul>
   </li>
</ul>

<!-- http://stackoverflow.com/questions/16417768/multi-level-ul-li-backbone-js -->