Skip to content

Instantly share code, notes, and snippets.

@aseemk
Created May 11, 2011 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aseemk/966214 to your computer and use it in GitHub Desktop.
Save aseemk/966214 to your computer and use it in GitHub Desktop.
Eco forEach iteration
<h2>For-Each</h2>
<p>
This should print a list of names, no?
(It does in EJS.)
</p>
<% names = ['Alice', 'Bob', 'Carol'] %>
<ul>
<% names.forEach (name) -> %>
<li><%= name %></li>
<% end %>
</ul>
<p>
Did it print anything?
</p>
_print _safe '<h2>For-Each</h2>\n\n<p>\n This should print a list of names, no?\n (It does in EJS.)\n</p>\n\n'
names = ['Alice', 'Bob', 'Carol']
_print _safe '\n\n<ul>\n'
names.forEach (name) ->
_capture ->
_print _safe '\n <li>'
_print name
_print _safe '</li>\n'
_print _safe '\n</ul>\n\n<p>\n Did it print anything?\n</p>\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment