Created
May 11, 2011 09:51
-
-
Save aseemk/966214 to your computer and use it in GitHub Desktop.
Eco forEach iteration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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