From 63ac6255ba3553b529f4b23846ec756b7a7a746d Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Sun, 8 May 2016 09:22:43 -0500 Subject: Cable: Generate .js or .coffee files while generating channel as per the javascript engine of the application - Now we will detect what javascript engine user is using and based on that we will generate either `.js` or `.coffee` version of the channel file. - This also needs a change in coffee-rails to override the `js_template` method. Related PR https://github.com/rails/coffee-rails/pull/72. - Currently coffee-rails gem sets `config.app_generators.javascript_engine` to `:coffee` and using this information we override the `js_template` to set the extension as `.coffee` in coffee-rails gem. - Using this approach, we can keep the `channel.js` and `channel.coffee` files in the Rails repository itself. - Additionally the `js_template` method can act as public interface for coffee-rails gem to hook into and change the extension to `.coffee` without maintaining the actual asset files. [Prathamesh Sonpatki, Matthew Draper] --- railties/lib/rails/generators/named_base.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'railties/lib/rails/generators/named_base.rb') diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index efbf51ddfb..ee076eb711 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -26,6 +26,10 @@ module Rails super end end + + def js_template(source, destination) + template(source + '.js', destination + '.js') + end end protected -- cgit v1.2.3