Created
May 11, 2011 09:43
-
-
Save aseemk/966202 to your computer and use it in GitHub Desktop.
Eco multi-line blocks and comments.
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
<h1>Multi-Line Blocks</h1> | |
<p> | |
It would be great to support multi-line blocks. | |
Here are some use cases: | |
</p> | |
<% | |
# Documentation via multiple lines of single-line comments. | |
# Like so. | |
%> | |
<% | |
# view logic that belongs together in a group. | |
# e.g. constants: | |
FOO = 'foo' | |
BAR = 'bar' | |
BAZ = 'baz' | |
%> | |
<% | |
# helper functions that really want to be multiple lines, | |
# e.g. for readability or inline code comments: | |
# make phrase suitable for use as id/class attribute | |
idify = (phrase) -> | |
phrase.toLowerCase() | |
.replace(/\s/g, '-') # replace whitespace w/ dashes | |
.replace(/[',?]/g, '') # strip punctuation | |
%> | |
<% | |
# or to comment out an entire block of HTML. | |
# this is better than <!-- ... --> both because it takes precedence | |
# but also because the commented HTML won't get sent to the client, | |
# which is good for perf but can also be useful for security, | |
# e.g. to put a FIXME for an XSS vulnerability. ;) | |
%> | |
<% ### | |
<p> | |
I don't want this HTML to show up in my output. | |
</p> | |
### %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment