Last active
March 29, 2016 20:31
-
-
Save markbrown4/d0380aa8ace8e71fe37c163c73b5857e to your computer and use it in GitHub Desktop.
cjsx is lovely, more natural and easier to read/write than JSX
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
| # 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