Closed eztinkerdreams closed 9 years ago
I see your grammar above is CoffeeScript (JSX)
, which I do not think is directly supported. It is likely detecting the .coffee
file extension and using CoffeeScript
instead.
CoffeeScript (CJSX)
is supported: https://github.com/Glavin001/atom-preview/blob/master/lib/renderer.coffee#L59-L65
You could try changing your grammar to that.
Or if you want you could submit a Pull Request adding the grammar Coffeescript (JSX)
and using https://github.com/jsdf/coffee-reactify
Thanks!
Thank you for the reply. Yes, this syntax is CoffeeScript with JSX .cjsx. As you can see in the screenshot, I have set the file type to Coffee (JSX), but the preview pain doesn't seem to honor this settings. Unfortunately the extension on these files is .coffee. I have configured ATOM via the customFileTypes settings to associate .coffee with the source type of 'source.coffee.jsx' so when I open the files, ATOM treats them as Coffee (JSX), but the preview pain still doesn't work, it errors out when it hits the JSX block. If I however change my file extensions to .cjsx, then everything works perfectly. Line 64 in this file associates the files with the .cjsx syntax. Is there a way for me to override this setting? https://github.com/Glavin001/atom-preview/blob/master/lib/renderer.coffee
I've just started using ATOM, so any help would be appreicated
Sounds like using CoffeeScript (CJSX)
works and CoffeeScript (JSX)
does not. Sounds like the grammar is not supported but the implementation for another preview renderer does work and can be reused.
I would recommend that you submit a simple Pull Request with the following:
renderer.coffee
and add CoffeeScript (JSX)
as another grammar. Currently only CoffeeScript (CJSX)
is supported.CoffeeScript (JSX)
as is already implemented for CoffeeScript (CJSX)
. You can copy from lines 56 to 65 here: https://github.com/Glavin001/atom-preview/blob/master/lib/renderer.coffee#L59-L65
That's it!I think this is a good article for how to load and edit a package: https://discuss.atom.io/t/load-developing-package/2554/11
Let me know if you have any specific questions about the above. Thanks!
With this update ATOM correctly auto selects JavaScript (JSX) as the file type. Then after updating the renderer.coffee file as you mentioned everything works as expected.
Thanks for the merge, can we get a version bump so that it comes down with package install?
Published to v0.16.4
I am attempting to see a preview of a CoffeeScript file that includes JSX syntax. The project depends on the https://github.com/jsdf/coffee-reactify module.
Changing the file extension to .cjsx works.