rails / coffee-rails

CoffeeScript adapter for the Rails asset pipeline. Also adds support for .coffee views.
MIT License
230 stars 64 forks source link

Doesn't Register Sprockets Transformer or Mime Type #82

Closed tomprats closed 7 years ago

tomprats commented 7 years ago

I've been familiarizing myself with Sprockets and how the Transformers and Processors work, but when I was trying to write a Preprocessor for Coffee I noticed I couldn't. I believe this gem handles converting Coffee to JS, but I was wondering why it uses an alternate route.

Is there any way to add preprocessors to it?

rafaelfranca commented 7 years ago

Which alternative route are you talking about?

tomprats commented 7 years ago

Sorry I'm not very familiar with how this gem works yet, but I was referring to using register_template_handler versus the sprockets register methods.

To add some context, I was working on building an alternative to https://github.com/jsdf/sprockets-coffee-react and my work so far is in https://github.com/tomprats/sprockets-cjsx. I had to add a transformer for coffee because I couldn't find a way to hook into this gem in the way a preprocessor would for sprockets.

guilleiguaran commented 7 years ago

@tomprats hello, actually this gem doesn't handle converting assets from coffee to js, this is done in sprockets itself in CoffeeScriptProcessor using the coffee-script gem that's a wrapper for coffee-script JS library executed in Ruby thanks to ExecJS

guilleiguaran commented 7 years ago

The included template handler and the register_template_handler method is for .coffee views living under app/views in Rails applications, not for Sprockets processors.

tomprats commented 7 years ago

Oh wow, thanks @guilleiguaran. I'll look into that. I misinterpreted the first part of the description "CoffeeScript adapter for the Rails asset pipeline". Thanks for all your help guys!