It’s just data

React.rb

Having determined that Angular.js is overkill for my blog rewrite, I started looking more closely at React.  It occurred to me that I could do better than JSX, so I wrote a Ruby2JS filter.  Compare for yourself.  Excerpt from the React tutorial:

var CommentList = React.createClass({
  render: function() {
    var commentNodes = this.props.data.map(function (comment) {
      return (
        <Comment author={comment.author}>
          {comment.text}
        </Comment>
      );
    });
    return (
      <div className="commentList">
        {commentNodes}
      </div>
    );
  }
});

Equivalent using the Ruby2JS filter:

class CommentList < React 
  def render
    _div.commentList do
      @@data.forEach do |comment|
        _CommentBlock comment.text, author: comment.author
      end
    end
  end
end

Note: I renamed the Comment class to CommentBlock to avoid a conflict with the existing Comment API.  I wouldn’t have thought that would be necessary, but things didn’t work until I made this change.

Full source for the tutorial reimplemented in Ruby is available.


Problem with Comment has been fixed.  Underlying cause was ruby2js attempting to us an ES6 feature: const.

Posted by Sam Ruby at

New Year is approaching very soon wish your friends and family members a very Happy New Year 2018 by sending them New Year 2018 Wishes happy new year 2018

Posted by happy new year 2018 at

I am feeling very nice to read this.
best kodi addons for movies
I will visit this blog regularly.

Posted by Mohit Jain at

I still liked this article, good, good content, and unique design.Thank you for sharing the article. 
Cara Menghilangkan Bekas Luka 
Cara Mengatasi Keputihan 
Obat Gondongan

Posted by Apotek Online at

Amazon Customer Care Number

Snapdeal Customer Care Number

Flipkart Customer Care Number

Paytm Customer Care Number

ICICI Customer Care Number

Posted by balvinder singh at

I truly appreciate this post. I’ve been looking everywhere for this! Thank goodness I found it on Bing. You’ve made my day! Thank you again!

Posted by Stromanbieter at

UP Land Records

Posted by Land record at

The blog or and best that is extremely useful to keep I can share the ideas of the future as this is really what I was looking for, I am very comfortable and pleased to come here. Thank you very much.
animal jam | five nights at freddy’s | hotmail login

Posted by animal jam at

Thank you so much! Really rich content and very useful information. I found my problem’s solution starting over here. I exceedingly advocate his/her machinery by means of the valuable enlightening information.
barney | abcya |starfall games

Posted by starfall at

Add your comment