5 ms·
One thing I like React is it is plain javascript. Therefore I can use coffeescript to describe the component: {div, p, ul, li} = React.DOM ... ren
by b6fan 12y ago
One thing I like React is it is plain javascript.
Therefore I can use coffeescript to describe the component:
{div, p, ul, li} = React.DOM
...
render: ->
div className: 'foo',
p className: 'bar', 'blabla'
p className: 'bar', 'blabla'
ul className: 'somelist',
@state.items.map (x) -> li key: x.id, x.content
If Riot.js uses a custom parser, it may not be able to do this.
- tipiirai 12y agoThe above is not possible with Riot.
- kailuowang 12y agoI still think that a declarative language is more suitable to describe the UI layout than a DSL built by non-declarative languages.
- woah 12y agoWouldn't this be possible with some preprocessing pipeline?
- evmar 12y agoThis no longer works in React 0.12 because they changed the element creation syntax. :\
- b6fan 12y agoActually I am using this syntax with React 0.12.1. React.DOM just work as expected. For custom components, prepend "React.createClass" with "React.createFactory". See http://jsfiddle.net/saxr8gLd/ http://jsfiddle.net/saxr8gLd/