4 ms·
I have found it easy enough to just use json-serializable literals to represent html, e.g: ['div', {id: 'main'}, ['h1', 'Some title'], ['p
by twfarland 12y ago
I have found it easy enough to just use json-serializable literals to represent html, e.g:
['div', {id: 'main'},
['h1', 'Some title'],
['p', 'Some text']]
I wrote a little function to turn this kind of thing into an html string (https://github.com/twfarland/don https://github.com/twfarland/don), but it could also be used as the view descriptor for some kind of view component ala React. Might work on that...
- wbkang 12y agoI like this a lot. I actually used this at work. With a simple function to translate JSON into DOM incrementally, it's a lot more succinct than JSX. And it's fully programmable in JS.