I'm using haml_coffee_assets in a Rails 3.2 application. The following works in an ejs template:
<table>
<tr>
<th></th>
</tr>
<% tutorials.each(function(model) { %>
<tr>
<td><%= model.escape('title') %>
</tr>
<% }); %>
</table>
I can't seem to get this working in haml_coffee. The following was my best guess but for some reason this haml_coffee template doesn't work:
%table
%thead
%tr
%th Tutorial Name
%tbody
- for tutorial in @tutorials
- do (model) ->
%tr
%td= model.title
All I get with this is:
ReferenceError: Can't find variable: model
Since you've mentioned that you're using Backbone on a GitHub issue, I assume that @tutorials
is a Backbone collection and you can use also this alternative:
%table
%thead
%tr
%th Tutorial Name
%tbody
- for model in @tutorials.models
%tr
%td= model.escape('title')