3 ms·
> but nested or complex HTML must get ugly fast That's the problem JSX solves - nesting tags and attributes is less syntactically onerous than managing a tree
by insin 12y ago
> but nested or complex HTML must get ugly fast
That's the problem JSX solves - nesting tags and attributes is less syntactically onerous than managing a tree of function calls or nested object structures, with their attendant braces and commas.
Here's the Mithril getting started example [1] done using JSX [2], for comparison (some of the other code has changed since I did this, but the rendering part looks the same)
[1] http://lhorie.github.io/mithril/getting-started.html#summary http://lhorie.github.io/mithril/getting-started.html#summary
[2] https://github.com/insin/msx/blob/master/test/jsx/example.jsx https://github.com/insin/msx/blob/master/test/jsx/example.js...
- kallussed 12y agoI like JSX, but I would say that Mithril + CoffeeScript is even nicer. A coffeescript example (not mine): http://www.reddit.com/r/javascript/comments/20pzbj/mithril_a_javascript_framework_for_building/ckfgfey http://www.reddit.com/r/javascript/comments/20pzbj/mithril_a... or https://github.com/Whoaa512/mithril-coffee-gulp-seed/blob/master/app/scripts/components/MyComponent.coffee https://github.com/Whoaa512/mithril-coffee-gulp-seed/blob/ma... Looks really clean...