Search code examples
javascriptbackbone.jserbejseco

backbone templates: index.jst.eco to index.jst.ejs


Specific question: this code works in a backbone template index.jst.eco, but it doesn't work in index.jst.ejs

<ui>

<% for entry in @entries.models: %>
<li> <%= entry.get('name') %></li>
<% end %>

</ui>

I'd like to know why (i.e. how to fix it for ejs), and, more generally, is there comprehensive documentation for how to write code in ejs templates? I can't find anything that goes into detail. As I've been playing around with ejs and eco, I've noticed the presence or absence of a : or a bracket can make a huge impact but I can't figure out how to know what to use and when.

I'm willing to use jst.eco or jst.ejs depending on which syntax has better documentation.


Solution

  • This is how that eco code would be written in jst.ejs.

       <% for (var i = 0; i < entries.length; i++) { %>
        <li> <%= entries.models[i].get('name') %></li>
        <% } %>
    

    However, I can't get it to work with a for entry in entries.models iterator