Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for triple-backticks and escaping backticks #4369

Merged
merged 2 commits into from
Nov 23, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions documentation/examples/embedded_block.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```
function time() {
return `The time is ${new Date().toLocaleTimeString()}`;
}
```
3 changes: 3 additions & 0 deletions documentation/examples/embedded_escaped.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
markdown = `function () {
return \`In Markdown, write code like \\\`this\\\`\`;
}`
13 changes: 13 additions & 0 deletions documentation/index.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,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 embed blocks of JavaScript using triple backticks. Within triple-backtick
blocks, single backticks are ignored.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within triple-backtick blocks, single backticks are ignored.

That sentence stood out a bit to me while first reading it. "Ignored – how? What exactly does that mean?" Then, I realized that the sentence probably exists to tell that it is a better idea to use triple-backticks than to escape backticks inside single-backtick blocks. If that's the case, perhaps change this paragraph to something like this:

You can also embed blocks of JavaScript using triple backticks. That's easier than escaping backticks, if you need them inside your JavaScript block.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would be an improvement.

</p>
<%= codeFor('embedded_block', 'time()') %>

<p>
<span id="switch" class="bookmark"></span>
Expand Down