Skip to content

Instantly share code, notes, and snippets.

@sebmarkbage
Created October 24, 2011 21:54
Show Gist options
  • Save sebmarkbage/1310443 to your computer and use it in GitHub Desktop.
Save sebmarkbage/1310443 to your computer and use it in GitHub Desktop.
CoffeeScript Whitespace After a Statement Creates an Object Context
###
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'
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