edgecase / dieter

Asset pipeline ring middleware
134 stars 22 forks source link

Coffeescript support? #1

Closed dmix closed 12 years ago

dmix commented 12 years ago

Would it be difficult to add coffeescript support?

I'm willing to give it a shot if its relatively straightforward.

CS depends on node for compilation though.

jxa commented 12 years ago

It is definitely something I would like to have in Dieter. I have not attempted to run coffeescript in rhino but I've seen that some people have had older versions running. Check out resources/vendor/less-wrapper.js for an example of how I was able to read a file from javascript. I'm also willing to help you out if you get stuck.

pbiggar commented 12 years ago

I'm trying to include haml-coffee, which requires both haml and coffeescript. It seems like this might be doable if instead of parsing using rhino (which is dead-ish I think), we use command-line programs from node to process it (somewhat like Rails programs do). What do you think?

pbiggar commented 12 years ago

Oh, here's the project I need to include: https://github.com/9elements/haml-coffee

dmix commented 12 years ago

I think the ruby asset pipeline is a much more complicated than running node via command line. It depends heavily on ExecJS which converts JS code into ruby objects: https://github.com/sstephenson/execjs

Although compiling the coffee files via command lien is relatively straightforward. The big question is it worth implementing vs compiling coffeescript the traditional way.

pbiggar commented 12 years ago

@dmix Ah, I'm not suggesting something that complex at all. Merely compiling the templates using programs installed via npm, and then possibly a lein assets:precompileto eagerly do the compilation.

pbiggar commented 12 years ago

Ah, never mind the precompilation, looks like rails_assets_coffee shows it can be done using rhino, for example: https://github.com/netzpirat/haml_coffee_assets/blob/master/lib/haml_coffee_assets/haml_coffee.rb. Am working on this now.

jxa commented 12 years ago

Implemented in #2