Last active
December 4, 2015 17:43
-
-
Save ryohey/a5c90f5c50e756bcb717 to your computer and use it in GitHub Desktop.
convert object to <ul><li> and <dl><dt><dd> in CoffeeScript for React.js
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
| json2html = (obj) -> | |
| if obj instanceof Array | |
| list = json2html o for o in obj | |
| <ul>{list}</ul> | |
| else if obj instanceof Object | |
| list = ([ | |
| <dt>{key}</dt> | |
| <dd>{json2html value}</dd> | |
| ] for key, value of obj) | |
| <dl>{list}</dl> | |
| else | |
| obj.toString() |
Author
ryohey
commented
Dec 4, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment