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

UPPSC Upper Subordinate Pre Exam Admit Card 2017

SSC Stenographer Vacancy 2017

RPSC 2nd Grade Teacher Admit Card 2017

Bihar Board Class 10th Results

Tamil Nadu Police Results 2017

Tamil Nadu TRB Recruitment 2017

BOB Sweeper Results 2017

Posted by balvinder singh at

Nice! I want you to thank for your time of this wonderful read!!! Your blog posts are more interesting and informative. I very like and visit regularly.
hill climb racing 2

Posted by hill climb racing 2 at

Quite nice this post also! This Ruby2JS commenting idea was trying to implement on a blog about watches and fashion and it work for the moment, but after an upgrade was a little bit tricky, so i will try to do this again, because seems quite useful and cool! Thanks and keep up the great work!

Posted by Laurafashionlover at

I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style.
Air Hostess Call Girls in Delhi

Posted by Delhi Escorts girls at

I really  impressed after visiting your website.Your website is  so good.Thanks for sharing with us.

Posted by escorts in Jaipur at

<a href=“http://topformtemplates.com/free-fax-cover-sheet-templates/">Webpage</a>  handling programming, with elements, for example, autocompletion, toolbars, thesaurus, and spelling choices.

Posted by Blog at

Efficient archive part creation [URL=http://topformtemplates.com/free-fax-cover-sheet-templates/]blog[/URL] Word preparing templates are conventionally included as a normal element in most word handling programming. What’s more, clients of such programming frequently have the choice to make and spare their own templates, to secure them from the first merchant of the product, or from outsiders.

Posted by Webpage at

This is great websites, I visited some of them but I didn’t know that Google offers free games.And this is I play free flash games in this websites.
- [link]
- [link]
- [link]

Posted by earn to die at

Thank you for giving them this great knowledge, really thank you for sharing, hope you will have such great posts as this more.

Posted by slither io at

I wouldn’t have suspected that would be vital, yet things didn’t work until the point that I rolled out this improvement. What’s more customers of such programming often have Order Dissertation the decision to make and extra their own particular formats, to secure them from the main shipper of the item, or from untouchables.

Posted by Order Dissertation at

If you are looking for an assignment that can help online in your assignment, then you will have to reach studentsassignmenthelp.com because our assignment writers provided the best of online dissertation proposal help. Assignment Writer is a Ph.D. Specialist who, before time, assignment access to university students.

Posted by Domenic Tylor at

Add your comment