New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added ability to use foo.js.coffee files in views. #1130
Conversation
That's a very well done pull request, thanks! But we need to handle this pull request in another way and probably for Rails 3.2. Maybe by partially supporting tilt, although they lack proper encoding support and other Rails features. |
Mind if I ask why another way? Not sure I understand why we this isn't the correct way to implement this. |
I can understand why refactoring the rendering engine to use Tilt would be a good idea. I just think this is a missing piece of functionality in 3.1 that people will be complaining about when it's released. I know this was one of the first things I tried to do in the beta and was disappointed to learn I couldn't use CoffeeScript instead of vanilla JS for my Ajax requests. |
Sure. If we add this as it is, we would be just duplicating code. And code duplication would easily lead for difference of behaviors from coffee being served from sprockets than rails. We should not have two code paths for this, but only one. |
I totally agree with your disappointment but it should be solved without duplicating the same JS preprocessor code that is already inside sprockets/tilt. |
Pretty disappointed with this one getting closed - the majority of the javascript in my app related to responding to ajax requests and this prevents me from using coffeescript for that. Please reconsider! |
That would easily work as a coffeescript-rails plugin. |
Would love to see this behavior in Rails 3.1, can't this be solved using just one code path then? |
+1 For this becoming part of Rails 3.1. Having CoffeeScript as the default and yet having to respond to ajax using vanilla JavaScript feels broken to me. |
It's available as gem: https://github.com/markbates/coffeebeans |
Regardless when and how this missing piece of functionality gets implemented in Rails itself, I think that we all can be in agreement that it should. While we wait for the final implementation we can use the available gem and then, hopefully easily, refactor whatever code we write now to use whatever solution the Rails team finally put in place. |
Once we have a fast, clean implementation, it's welcome in core. 3.2 is a more likely target, though. |
Just wanted to put my vote here for this functionality. I tried to use coffeescript in an xhr request but it didn't work. Great that it'll probably be in 3.2 so for now I'll go grab the gem by markbates. Thanks! |
As I understand, this approach compiles CoffeeScript every time even in production. So here is alternative as a gem coffee-views. |
This is almost the same as coffee beans. Why not merge these fixes into that gem so there's only one? I'll gladly pull the changes in. There are a lot of people using coffee beans already and they'd probably really like the changes. |
@markbates I can prepare pull request, if you ok with <%=%> changes. |
Can you explain them a bit more? Not sure I really understand what they do? Do they wrap everything in the j method? |
Just ran into this myself, putting together the next version of Rails for Zombies. If you're going to recommend people use CoffeeScript in their new Rails applications, then you should allow them to use JUST CoffeeScript in their Rails applications. I understand there may be architectural issues, I'm just going to have to teach all new Rails developers to use Mark Bates's Gem. |
Can you include the coffeebeans gem in the Gemfile by default? |
The HTML5 Boilerplate based application template adds this mark's gem to https://github.com/russfrisch/h5bp-rails/blob/master/h5bp.rb#L65 Hopefully this functionality makes it into rails core soon. Like Gregg, I On Fri, Aug 12, 2011 at 11:04 AM, joefiorini <
|
Now this supported in Rails 3.1 through the coffee-rails plugin (included by default in Gemfle) |
Glad this is somewhat included in rails 3.1. I would love to have seen this touted as part ofbthe last RC. I don't recall seeing that change in the list. |
rather than allow a |
I just faced this problem today. I have also the opinion of including coffeebeans in Gemfile by default, or telling about this problem in the docs instead. |
Despite support for Coffeescript view templates we still have a problem whereby |
With this patch it is now possible to use CoffeeScript to respond to JS requests.