Improvements to strings and comments docs; could be back-ported to v1 docs
This commit is contained in:
parent
58f9428c58
commit
c8a3c1a6fd
|
@ -0,0 +1 @@
|
|||
code = 2 * 617 # The code is 1234
|
|
@ -0,0 +1,13 @@
|
|||
## Comments
|
||||
|
||||
In CoffeeScript, comments are denoted by the `#` character. Everything from a `#` to the end of the line is ignored by the compiler, and will be excluded from the JavaScript output.
|
||||
|
||||
```
|
||||
codeFor('comment')
|
||||
```
|
||||
|
||||
Sometimes you’d like to pass a block comment through to the generated JavaScript. For example, when you need to embed a licensing header at the top of a file. Block comments, which mirror the syntax for block strings, are preserved in the generated output.
|
||||
|
||||
```
|
||||
codeFor('block_comment')
|
||||
```
|
|
@ -1,6 +1,6 @@
|
|||
## String Interpolation, Block Strings, and Block Comments
|
||||
## Strings
|
||||
|
||||
Ruby-style string interpolation is included in CoffeeScript. Double-quoted strings allow for interpolated values, using `#{ … }`, and single-quoted strings are literal. You may even use interpolation in object keys.
|
||||
Like JavaScript and many other languages, CoffeeScript supports strings as delimited by the `"` or `'` characters. CoffeeScript also supports string interpolation within `"`-quoted strings, using `#{ … }`. Single-quoted strings are literal. You may even use interpolation in object keys.
|
||||
|
||||
```
|
||||
codeFor('interpolation', 'sentence')
|
||||
|
@ -12,16 +12,10 @@ Multiline strings are allowed in CoffeeScript. Lines are joined by a single spac
|
|||
codeFor('strings', 'mobyDick')
|
||||
```
|
||||
|
||||
Block strings 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 block is maintained throughout, so you can keep it all aligned with the body of your code.
|
||||
Block strings, delimited by `"""` or `'''`, 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 block is maintained throughout, so you can keep it all aligned with the body of your code.
|
||||
|
||||
```
|
||||
codeFor('heredocs', 'html')
|
||||
```
|
||||
|
||||
Double-quoted block strings, like other double-quoted strings, allow interpolation.
|
||||
|
||||
Sometimes you’d like to pass a block comment through to the generated JavaScript. For example, when you need to embed a licensing header at the top of a file. Block comments, which mirror the syntax for block strings, are preserved in the generated code.
|
||||
|
||||
```
|
||||
codeFor('block_comment')
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue