Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Additional layers of pre-processing, js.coffee.erb? #13

JeanMertz opened this Issue Sep 24, 2011 · 8 comments


None yet
7 participants

In the Ruby on Rails Asset Pipeline Guide they talk about preprocessing by chaining these preprocessors to the filename.

I can't seem to get it to work with coffee-rails however (meaning, not using it in the asset pipeline, but in js views for ajax callbacks).

Is this a known issue/limitation of this implementation at the moment? Or is there something else going on here?

/app/views/pages/update.js.coffee works
/app/views/pages/update.js.erb works (but I can't write in coffee script, obviously
/app/views/pages/update.js.coffee.erb does not work

2011-09-24 18:28:36 [INFO ] Completed 500 Internal Server Error in 290ms

ActionView::MissingTemplate (Missing template pages/update, application/update with {:handlers=>[:erb, :builder, :coffee, :haml], :formats=>[:js, "application/ecmascript", "application/x-ecmascript", :html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json], :locale=>[:nl, :nl]}. Searched in:
  * "/Users/Jean/nulvierdrie/manager/source/manager/app/views"

2011-09-24 18:28:36 [INFO ] Rendered /Users/Jean/.rvm/gems/ruby-1.9.3-preview1@manager/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/missing_template.erb within rescues/layout (0.3ms)

Scrap that, you don't actually need the .erb extension. It simply works with js.coffee. My bad (but a bit confusing).

@JeanMertz JeanMertz closed this Sep 24, 2011

This is extremely confusing. Rails should support rendering foo.js.coffee.erb, not foo.js.coffee. foo.js.coffee should be untouched by ERB. Is there an open issue for this?

ncri commented Dec 4, 2011

And what if you like to use haml? Like foo.js.coffee.haml ? Assume this is not supported yet?

Yeah this is quite confusing in my opinion as well, definitely goes against the principle of least surprise

I think the issue is that you're not supposed to use the asset pipeline compilers dynamically in production, so that's why a file.js.coffee.erb will work no problems in the asset dir, but will fail (get blocked/ignored by rails?) in the views dir

Please correct me if i'm wrong

I think this should be re-opened. As @joshsz points out the way this currently works is confusing and non-intuitive.

@3amsleep: It looks like coffee-rails now provides support for Coffeescript view templates. I think those comments on the old issues talking about Coffeescript only being available in the asset pipeline are no longer correct.

See related issue #36

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