mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Docs for triple-backticks and escaping backticks (#4369)
* Documentation for triple backticks and escaping backticks * Better explanation of escaped backticks within triple-backticks block
This commit is contained in:
5
documentation/examples/embedded_block.coffee
Normal file
5
documentation/examples/embedded_block.coffee
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
function time() {
|
||||
return `The time is ${new Date().toLocaleTimeString()}`;
|
||||
}
|
||||
```
|
||||
3
documentation/examples/embedded_escaped.coffee
Normal file
3
documentation/examples/embedded_escaped.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
markdown = `function () {
|
||||
return \`In Markdown, write code like \\\`this\\\`\`;
|
||||
}`
|
||||
@@ -901,6 +901,19 @@ Block
|
||||
use backticks to pass it straight through.
|
||||
</p>
|
||||
<%= codeFor('embedded', 'hi()') %>
|
||||
<p>
|
||||
Escape backticks with backslashes: <code>\`</code> becomes <code>`</code>.
|
||||
</p>
|
||||
<p>
|
||||
Escape backslashes before backticks with more backslashes: <code>\\\`</code>
|
||||
becomes <code>\`</code>.
|
||||
</p>
|
||||
<%= codeFor('embedded_escaped', 'markdown()') %>
|
||||
<p>
|
||||
You can also embed blocks of JavaScript using triple backticks. That's easier
|
||||
than escaping backticks, if you need them inside your JavaScript block.
|
||||
</p>
|
||||
<%= codeFor('embedded_block', 'time()') %>
|
||||
|
||||
<p>
|
||||
<span id="switch" class="bookmark"></span>
|
||||
|
||||
Reference in New Issue
Block a user