Skip to content

Instantly share code, notes, and snippets.

@davemo
Last active September 15, 2016 08:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davemo/8199114 to your computer and use it in GitHub Desktop.
Save davemo/8199114 to your computer and use it in GitHub Desktop.
A .coffee file with Reacts JSX, compiles fine in Sublime Text using 'Coffee: Display JavaScript', but won't compile with the coffeescript CLI or the coffeeify transform for browserify. Relevant reading: http://blog.vjeux.com/2013/javascript/react-coffeescript.html and https://groups.google.com/forum/#!msg/reactjs/NHy6UNqm-zU/i6Xr0-jP7nIJ
`/** @jsx React.DOM */`
React = require("react")
$ = require("jquery-browserify")
converter = new Showdown.converter
Comment = React.createClass
render: ->
rawMarkup = converter.makeHtml @props.children.toString()
`<div className="comment">
<h2 className="comment">{this.props.author}</h2>
<span dangerouslySetInnerHTML={{__html: rawMarkup}} />
</div>`
/** @jsx React.DOM */;
var $, Comment, React, converter;
React = require("react");
$ = require("jquery-browserify");
converter = new Showdown.converter;
Comment = React.createClass({
render: function() {
var rawMarkup;
rawMarkup = converter.makeHtml(this.props.children.toString());
return <div className="comment">
<h2 className="comment">{this.props.author}</h2>
<span dangerouslySetInnerHTML={{__html: rawMarkup}} />
</div>;
}
});
$ coffee app/js/app.coffee
/Users/davidmosher/code/react/tbs-battle-planner/app/js/app.coffee:15
return <div className="comment">
^
SyntaxError: Unexpected token <
at Module._compile (module.js:439:25)
@davemo
Copy link
Author

davemo commented Dec 31, 2013

So, it does compile with the -c flag which is what I was missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment