Skip to content
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

Sprockets 4 support #135

Merged
merged 1 commit into from
Dec 19, 2015
Merged

Sprockets 4 support #135

merged 1 commit into from
Dec 19, 2015

Conversation

tjgrathwell
Copy link
Contributor

I was trying to update an app to test out the latest Rails master, and found this gem was incompatible because it doesn't support Sprockets 4.

Apparently, the plugin architecture has changed such that Sprockets now requires you to install extensions like this:

config.assets.configure do |env|
  env.register_mime_type 'text/x-handlebars-template', extensions: Config.handlebars_extensions
  env.register_transformer 'text/x-handlebars-template', 'application/javascript', HandlebarsProcessor
end

Instead of the old way,

sprockets_environment.register_engine('.hbs', HandlebarsTemplate)

Additionally, the thing that gets registered now responds only to call, instead of using the Tilt interface. (See https://github.com/rails/sprockets/blob/da25579535aabf6935facd8c626f6588a90ad9f8/README.md#processor-interface in the Sprockets readme for a little more detail)

This commit attempts to use the new syntax on Sprockets 4 and up, while preserving the old syntax if the gem is used on a Sprockets 3 project.

@AlexRiedler
Copy link
Collaborator

@tjgrathwell see any reason not to go ahead and merge this ? How much manual testing have you done ?

@tjgrathwell
Copy link
Contributor Author

I've tested it on https://github.com/railsbridge/bridge_troll in both the existing Rails 4.2 / Sprockets 3 master branch and this Rails Edge / Sprockets 4 branch. Seems to work?

@tjgrathwell
Copy link
Contributor Author

This should work for Sprockets 3 as well, see for reference some prior art at reactjs/react-rails@c8ecba2 for react-rails. Let me know if you want me to change the PR from Gem::Version.new(Sprockets::VERSION) < Gem::Version.new('4') to Gem::Version.new(Sprockets::VERSION) < Gem::Version.new('3')

@AlexRiedler
Copy link
Collaborator

@tjgrathwell merging this, then going to do some testing ; potentially refactor some small stuff before releasing

AlexRiedler added a commit that referenced this pull request Dec 19, 2015
@AlexRiedler AlexRiedler merged commit 50ebc8b into leshill:master Dec 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants