mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
heredoc docs
This commit is contained in:
parent
477c510345
commit
c8d505e85d
5 changed files with 36 additions and 6 deletions
5
documentation/coffee/heredocs.coffee
Normal file
5
documentation/coffee/heredocs.coffee
Normal file
|
@ -0,0 +1,5 @@
|
|||
html: '''
|
||||
<strong>
|
||||
cup of coffeescript
|
||||
</strong>
|
||||
'''
|
|
@ -79,7 +79,7 @@
|
|||
<a href="#embedded">Embedded JavaScript</a><br />
|
||||
<a href="#switch">Switch/When/Else</a><br />
|
||||
<a href="#try">Try/Catch/Finally</a><br />
|
||||
<a href="#strings">Multiline Strings</a><br />
|
||||
<a href="#strings">Multiline Strings and Heredocs</a><br />
|
||||
<a href="#resources">Resources</a><br />
|
||||
<a href="#contributing">Contributing</a><br />
|
||||
<a href="#change_log">Change Log</a><br />
|
||||
|
@ -556,10 +556,17 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
|
|||
<%= code_for('try') %>
|
||||
|
||||
<p id="strings">
|
||||
<b class="header">Multiline Strings</b>
|
||||
<b class="header">Multiline Strings and Heredocs</b>
|
||||
Multiline strings are allowed in CoffeeScript.
|
||||
</p>
|
||||
<%= code_for('strings', 'moby_dick') %>
|
||||
<p>
|
||||
Heredocs can be used to hold formatted or indentation-sensitive text
|
||||
(or, if you just don't feel like escaping quotes and apostrophes). The
|
||||
indentation level that begins the heredoc is maintained throughout, so
|
||||
you can keep it all aligned with the body of your code.
|
||||
</p>
|
||||
<%= code_for('heredocs') %>
|
||||
|
||||
<h2 id="resources">Resources</h2>
|
||||
|
||||
|
|
4
documentation/js/heredocs.js
Normal file
4
documentation/js/heredocs.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
(function(){
|
||||
var html;
|
||||
html = "<strong>\n cup of coffeescript\n</strong>";
|
||||
})();
|
18
index.html
18
index.html
|
@ -65,7 +65,7 @@
|
|||
<a href="#embedded">Embedded JavaScript</a><br />
|
||||
<a href="#switch">Switch/When/Else</a><br />
|
||||
<a href="#try">Try/Catch/Finally</a><br />
|
||||
<a href="#strings">Multiline Strings</a><br />
|
||||
<a href="#strings">Multiline Strings and Heredocs</a><br />
|
||||
<a href="#resources">Resources</a><br />
|
||||
<a href="#contributing">Contributing</a><br />
|
||||
<a href="#change_log">Change Log</a><br />
|
||||
|
@ -1309,7 +1309,7 @@ return [document.title, "Hello JavaScript"].join(": ");
|
|||
</pre><br class='clear' /></div>
|
||||
|
||||
<p id="strings">
|
||||
<b class="header">Multiline Strings</b>
|
||||
<b class="header">Multiline Strings and Heredocs</b>
|
||||
Multiline strings are allowed in CoffeeScript.
|
||||
</p>
|
||||
<div class='code'><pre class="idle"><span class="FunctionName">moby_dick</span><span class="Keyword">:</span> <span class="String"><span class="String">"</span>Call me Ishmael. Some years ago --</span>
|
||||
|
@ -1335,6 +1335,20 @@ to interest me on shore, I thought I would sail \
|
|||
about a little and see the watery part of the \
|
||||
world...";
|
||||
;alert(moby_dick);'>run: moby_dick</button><br class='clear' /></div>
|
||||
<p>
|
||||
Heredocs can be used to hold formatted or indentation-sensitive text
|
||||
(or, if you just don't feel like escaping quotes and apostrophes). The
|
||||
indentation level that begins the heredoc is maintained throughout, so
|
||||
you can keep it all aligned with the body of your code.
|
||||
</p>
|
||||
<div class='code'><pre class="idle"><span class="FunctionName">html</span><span class="Keyword">:</span> <span class="String"><span class="String">'</span><span class="String">'</span></span><span class="String"><span class="String">'</span></span>
|
||||
<span class="String"> <strong></span>
|
||||
<span class="String"> cup of coffeescript</span>
|
||||
<span class="String"> </strong></span>
|
||||
<span class="String"> <span class="String">'</span></span><span class="String"><span class="String">'</span><span class="String">'</span></span>
|
||||
</pre><pre class="idle"><span class="Storage">var</span> html;
|
||||
html <span class="Keyword">=</span> <span class="String"><span class="String">"</span><strong><span class="UserDefinedConstant">\n</span> cup of coffeescript<span class="UserDefinedConstant">\n</span></strong><span class="String">"</span></span>;
|
||||
</pre><br class='clear' /></div>
|
||||
|
||||
<h2 id="resources">Resources</h2>
|
||||
|
||||
|
|
4
test/fixtures/execution/test_heredocs.coffee
vendored
4
test/fixtures/execution/test_heredocs.coffee
vendored
|
@ -8,11 +8,11 @@ print(a is "basic heredoc\non two lines")
|
|||
|
||||
a: '''
|
||||
a
|
||||
b
|
||||
"b
|
||||
c
|
||||
'''
|
||||
|
||||
print(a is "a\n b\nc")
|
||||
print(a is "a\n \"b\nc")
|
||||
|
||||
|
||||
a: '''one-liner'''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue