Skip to content

Instantly share code, notes, and snippets.

@markbrown4
Last active March 29, 2016 20:31
Show Gist options
  • Select an option

  • Save markbrown4/d0380aa8ace8e71fe37c163c73b5857e to your computer and use it in GitHub Desktop.

Select an option

Save markbrown4/d0380aa8ace8e71fe37c163c73b5857e to your computer and use it in GitHub Desktop.
cjsx is lovely, more natural and easier to read/write than JSX
# implicit returns, simpler than bullshitting around with return ()
ThreadList = (props)->
<ul id="threads">
<ThreadListItem threads={props.threads} />
</ul>
# everything as an expression FTW
# for loops more natural than map, no bullshitting around with binding this
<ul id="threads">
{ for thread in props.threads
<ThreadItem thread={thread} />
}
</ul>
# if / else, no bullshitting around with ternary and nulls
ThreadItem = ->
<div>
{ if thread.active
<span>Active</span>
else
<span>Inactive</span>
}
</div>
# @ shorthand saves a lot of keystrokes
<ul id="threads">
{ for thread in @state.threads
<ThreadItem thread={thread} />
}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment