7

There is a classic React component:

var CommentForm = React.createClass({
  render: function() {
    return (
      <form className="commentForm">
        <input type="text" placeholder="Your name" />
        <input type="text" placeholder="Say something..." />
        <input type="submit" value="Post" />
      </form>
    );
  }
});

Is it possible to use Slim instead of HTML? Something like this:

var CommentForm = React.createClass({
  render: function() {
    return (
      form.commentForm
        input type="text" placeholder="Your name"
        input type="text" placeholder="Say something..."
        input type="submit" value="Post"
    );
  }
});
knowbody
  • 8,106
  • 6
  • 45
  • 70
  • 1
    There isn't a way to do this now. – Jordan Running Jul 11 '15 at 22:01
  • 1
    In that *classic* example, that is **not** HTML. It is JSX. JSX compiles to JavaScript commands that run against the virtual DOM. ASAIK, this is the only markup available at the moment. – Davin Tryon Jul 11 '15 at 23:10
  • Thanks guys. I didn't know that is not HTML –  Jul 11 '15 at 23:22
  • 1
    If React.js source code is hackable enough then one could, hypothetically, add any kind of language replacing JSX. When React will become a de-facto standard on the web (!) we will see more and more template languages supported (dreaming). – Peter Dec 13 '15 at 15:06
  • 1
    That's one of reasons people not using ReactJS. JSX force you write raw html instead your favorite template language. Take a look of how react- Jade handle this https://github.com/pugjs/react-jade. Slim could be done in similar way. – Tim Wu Feb 19 '16 at 06:35

0 Answers0