Mislav Marohnić
2011-May-23 01:08 UTC
Rails 3.1: why ".css.scss" and ".js.coffee" extensions?
Rails 3.1 generators* create stubs for ".css.scss" and ".js.coffee" files in "app/assets/" directory. Why the double extension? It made sense in view templates (e.g. "index.html.erb") because of the request formats and the fact that some template engines can render multiple types of output, not just html. Assets don''t have request formats nor can Sass and CoffeeScript render anything but CSS and JavaScript. I understand this might have been an attempt to preserve the current "naming convention", but is it worth preserving this "convention" now that it lost its meaning? [*]: https://github.com/rails/rails/blob/ba3ea9c/railties/lib/rails/generators/rails/assets/assets_generator.rb#L28-36 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Ken Collins
2011-May-23 01:27 UTC
Re: Rails 3.1: why ".css.scss" and ".js.coffee" extensions?
I think these extensions are just the hints to call a chain of template renderers under Sprockets & Tilt. So .js.coffee.erb would first render with ERB, then CoffeeScript. I read thru the Sprockets & Tilt source and you can just keep tacking these things on. Pretty clever in my book. About the only thing I have run into that is not an issue with either of these libraries is getting my editor to focus on the proper language scope. For instance, if I were editing a a foo.css.scss.erb I would want my editor to not use my normal erb language theme but instead .scss. This is easily solvable on my own end tho. - Ken On May 22, 2011, at 9:08 PM, Mislav Marohnić wrote:> Rails 3.1 generators* create stubs for ".css.scss" and ".js.coffee" files in "app/assets/" directory. > > Why the double extension? It made sense in view templates (e.g. "index.html.erb") because of the request formats and the fact that some template engines can render multiple types of output, not just html. > > Assets don''t have request formats nor can Sass and CoffeeScript render anything but CSS and JavaScript. > > I understand this might have been an attempt to preserve the current "naming convention", but is it worth preserving this "convention" now that it lost its meaning? > > > [*]: https://github.com/rails/rails/blob/ba3ea9c/railties/lib/rails/generators/rails/assets/assets_generator.rb#L28-36 > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Paul Campbell
2011-May-23 06:45 UTC
Re: Rails 3.1: why ".css.scss" and ".js.coffee" extensions?
> I think these extensions are just the hints to call a chain of template > renderers under Sprockets & Tilt. So .js.coffee.erb would first render with > ERB, then CoffeeScript. I read thru the Sprockets & Tilt source and you can > just keep tacking these things on. Pretty clever in my book.Yep : DHH showed this exact feature last week at RailsConf.> About the only thing I have run into that is not an issue with either of > these libraries is getting my editor to focus on the proper language > scope. For instance, if I were editing a a foo.css.scss.erb I would want my > editor to not use my normal erb language theme but instead .scss. This is > easily solvable on my own end tho. > > - Ken > On May 22, 2011, at 9:08 PM, Mislav Marohnić wrote: > > Rails 3.1 generators* create stubs for ".css.scss" and ".js.coffee" files in > "app/assets/" directory. > Why the double extension? It made sense in view templates (e.g. > "index.html.erb") because of the request formats and the fact that some > template engines can render multiple types of output, not just html. > Assets don''t have request formats nor can Sass and CoffeeScript render > anything but CSS and JavaScript. > I understand this might have been an attempt to preserve the current "naming > convention", but is it worth preserving this "convention" now that it lost > its meaning? > > [*]: > https://github.com/rails/rails/blob/ba3ea9c/railties/lib/rails/generators/rails/assets/assets_generator.rb#L28-36 > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. >-- Paul Campbell paul@hypertiny.ie - - - - - - - - - - - - - - - - - - - web http://hypertiny.ie blog http://www.pabcas.com twitter http://www.twitter.com/paulca github http://www.github.com/paulca phone +353 87 914 8162 - - - - - - - - - - - - - - - - - - - -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On Monday, May 23, 2011 8:45:58 AM UTC+2, paulca wrote:> > > I think these extensions are just the hints to call a chain of template > > renderers under Sprockets & Tilt. So .js.coffee.erb would first render > with > > ERB, then CoffeeScript. I read thru the Sprockets & Tilt source and you > can > > just keep tacking these things on. Pretty clever in my book. > > Yep : DHH showed this exact feature last week at RailsConf. >That''s pretty rad, but it doesn''t explain what are ".js" and ".css" hints for. I''m pretty sure that the whole Sprockets feature stack would work even without those. I''m wondering about the rationale of making this the default recommended style (by making generators create them). -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Steve Klabnik
2011-May-23 22:44 UTC
Re: Rails 3.1: why ".css.scss" and ".js.coffee" extensions?
They get served in /assets, and so you wouldn''t be able to tell the difference between the end /assets/application.js and /assets/application.css This doesn''t mean the intermediate ones couldn''t have them stripped, but whatever. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Paul Campbell
2011-May-24 09:22 UTC
Re: Rails 3.1: why ".css.scss" and ".js.coffee" extensions?
> That''s pretty rad, but it doesn''t explain what are ".js" and ".css" hints > for. > > I''m pretty sure that the whole Sprockets feature stack would work even > without those. I''m wondering about the rationale of making this the default > recommended style (by making generators create them).Feels pretty consistent to me : *.html.erb, *.js.erb *.css.erb> > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. >-- Paul Campbell paul@hypertiny.ie - - - - - - - - - - - - - - - - - - - web http://hypertiny.ie blog http://www.pabcas.com twitter http://www.twitter.com/paulca github http://www.github.com/paulca phone +353 87 914 8162 - - - - - - - - - - - - - - - - - - - -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Got an official answer: https://twitter.com/#!/rails/status/73140918739406848 It comes down to two reasons: keeping the convention from regular views, and exposing the feature of Sprockets where asset processors can be stacked (also discussed on this thread). -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.