Add rails-erb-loader for ERB support #19

Merged
merged 1 commit into from Dec 15, 2016

Conversation

Projects
None yet
2 participants
@guilleiguaran
Member

guilleiguaran commented Dec 11, 2016

This allow to get support for ERB inside of JS files, e.g you can put Ruby code inside of a .js.erb file to be able to access to asset pipeline files:

// app/javascripts/packs/application.js.erb
var imgPath = '<%= ActionController::Base.helpers.asset_path "rails.png" %>';
console.log(imgPath);

is compiled to:

var a="/assets/rails-03bb170d74e34a9d3ab9157113c6ab68d2eb4a61a1a7ec5f77e45bc55d9e168e.png";
console.log(a);
@guilleiguaran

This comment has been minimized.

Show comment
Hide comment
@guilleiguaran

guilleiguaran Dec 11, 2016

Member

btw, I'm waiting for usabilityhub/rails-erb-loader#21 before of getting this merged to change the option name from rails to runner.

Member

guilleiguaran commented Dec 11, 2016

btw, I'm waiting for usabilityhub/rails-erb-loader#21 before of getting this merged to change the option name from rails to runner.

@guilleiguaran guilleiguaran referenced this pull request in usabilityhub/rails-erb-loader Dec 11, 2016

Merged

Allow use of custom executable and erb engine #21

lib/install/config/shared.js
+ test: /\.erb$/,
+ loader: 'rails-erb-loader',
+ query: {
+ rails: '../bin/rails'

This comment has been minimized.

@guilleiguaran

guilleiguaran Dec 11, 2016

Member

After of getting usabilityhub/rails-erb-loader#21 this needs to be changed to

runner: '../bin/rails runner'

@guilleiguaran

guilleiguaran Dec 11, 2016

Member

After of getting usabilityhub/rails-erb-loader#21 this needs to be changed to

runner: '../bin/rails runner'

@guilleiguaran

This comment has been minimized.

Show comment
Hide comment
@guilleiguaran

guilleiguaran Dec 14, 2016

Member

This is ready for merge.

@dhh do you think ERB support should be a default in webpacker or that we should add this to docs instead?

Member

guilleiguaran commented Dec 14, 2016

This is ready for merge.

@dhh do you think ERB support should be a default in webpacker or that we should add this to docs instead?

@dhh

This comment has been minimized.

Show comment
Hide comment
@dhh

dhh Dec 14, 2016

Member

Yeah, I think this is great. Gives us an immediate solution to getting digested stamps from the asset pipeline, even though I'd prefer a pure JS solution as well.

Member

dhh commented Dec 14, 2016

Yeah, I think this is great. Gives us an immediate solution to getting digested stamps from the asset pipeline, even though I'd prefer a pure JS solution as well.

@guilleiguaran guilleiguaran merged commit 683fa5f into master Dec 15, 2016

@guilleiguaran guilleiguaran deleted the erb-preloader branch Dec 15, 2016

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