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:
Geoffrey Booth 2016-11-22 22:09:35 -08:00 committed by GitHub
parent 8ea67ff3e9
commit 992eb49e92
3 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,5 @@
```
function time() {
return `The time is ${new Date().toLocaleTimeString()}`;
}
```

View File

@ -0,0 +1,3 @@
markdown = `function () {
return \`In Markdown, write code like \\\`this\\\`\`;
}`

View File

@ -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>