Hacker News new | ask | show | jobs
by b6fan 4159 days 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.
4 comments

I still think that a declarative language is more suitable to describe the UI layout than a DSL built by non-declarative languages.
This no longer works in React 0.12 because they changed the element creation syntax. :\
Actually 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/
Wouldn't this be possible with some preprocessing pipeline?
The above is not possible with Riot.