| 1 | <h2>Comments</h2> |
| 2 | <pre><code># This is a comment |
| 3 | ### This is a |
| 4 | multi-line comment###</code></pre> |
| 5 | |
| 6 | <h2>Strings</h2> |
| 7 | <pre><code>'foo \'bar\' baz' |
| 8 | "foo \"bar\" baz" |
| 9 | 'Multi-line |
| 10 | strings are supported' |
| 11 | "Multi-line |
| 12 | strings are supported" |
| 13 | ''' 'Block strings' |
| 14 | are supported too''' |
| 15 | """ "Block strings" |
| 16 | are supported too"""</code></pre> |
| 17 | |
| 18 | <h2>String interpolation</h2> |
| 19 | <pre><code>"String #{interpolation} is supported" |
| 20 | 'This works #{only} between double-quoted strings'</code></pre> |
| 21 | |
| 22 | <h2>Object properties</h2> |
| 23 | <pre><code>kids = |
| 24 | brother: |
| 25 | name: "Max" |
| 26 | age: 11 |
| 27 | sister: |
| 28 | name: "Ida" |
| 29 | age: 9</code></pre> |
| 30 | |
| 31 | <h2>Regexps</h2> |
| 32 | <pre><code>/normal [r]egexp?/; |
| 33 | /// ^( |
| 34 | mul\t[i-l]ine |
| 35 | regexp # with embedded comment |
| 36 | ) ///</code></pre> |
| 37 | |
| 38 | <h2>Classes</h2> |
| 39 | <pre><code>class Animal |
| 40 | constructor: (@name) -> |
| 41 | move: (meters) -> |
| 42 | alert @name + " moved #{meters}m." |
| 43 | |
| 44 | class Snake extends Animal |
| 45 | move: -> |
| 46 | alert "Slithering..." |
| 47 | super 5 |
| 48 | |
| 49 | class Horse extends Animal |
| 50 | move: -> |
| 51 | alert "Galloping..." |
| 52 | super 45 |
| 53 | |
| 54 | sam = new Snake "Sammy the Python" |
| 55 | tom = new Horse "Tommy the Palomino" |
| 56 | |
| 57 | sam.move() |
| 58 | tom.move()</code></pre> |
| 59 | |
| 60 | <h2>Inline JavaScript</h2> |
| 61 | <pre><code>`alert("foo")`</code></pre> |