Created
October 24, 2011 21:54
-
-
Save sebmarkbage/1310443 to your computer and use it in GitHub Desktop.
CoffeeScript Whitespace After a Statement Creates an Object Context
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
The indentation on a line following a statement creates an implicit variable. | |
That variable can be reused by placing more statements on the same whitespace level. | |
### | |
createElement 'a' | |
.style | |
.width = 100 | |
.height = 100 | |
.setAttribute 'href', 'http://...' | |
.appendChild | |
createElement 'strong' | |
.textContent = 'foo' | |
.appendChild | |
createTextNode 'bar' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = createElement('a'), | |
a_style = a.style; | |
a_style.width = 100; | |
a_style.height = 100; | |
a.setAttribute('href', 'http://...'); | |
var strong = createElement('strong'); | |
strong.textContent = 'foo'; | |
a.appendChild(strong); | |
a.appendChild(createTextNode('bar')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment