Closed kirs closed 9 years ago
/cc @tricknotes
It seems sprockets-rails issue for me.
sprockets-rails version | working? |
---|---|
2.2.4 | o |
3.0.0.beta.1 | o |
master | x |
I'll check about more detail in this weekend.
sprockets-rails version working? 2.2.4 o 3.0.0.beta.1 o master x
Note: All of them are tested with sprockets 3.0.0.
Ar right. Probably you mean the same fix as https://github.com/reactjs/react-rails/pull/241 is required in ember-rails too.
Thanks for the fast reply! Let me try 3.0.0.beta.1
Actually the fix I sent to react-rails doesn't work with test env: https://github.com/reactjs/react-rails/pull/241#issuecomment-92715133
This is weird, but I see that 3.0.0.beta.1
actually depends on Sprockets 2.x: https://rubygems.org/gems/sprockets-rails/versions/3.0.0.beta1
@josh any thoughts?
I haven't see the code, but I have a pretty good bet I know whats wrong.
You only want to touch Rails.application.assets
inside a configure
block if you using an initializer. Otherwise it depends on the unpredictable order that someones initializers end up running in.
config.assets.configure do |env|
env.append_path ...
env.register_processor ..
end
If you just touching paths
, I think you can just modify config.assets.paths <<
. That may have slightly different semantics. But the configure block suggestion should work the same. Its totally backwards compatible since the plugin existed. It was mostly a bug that the old code path seemly worked sometimes.
Hope that helps, feel free to @mention on the proposed PR.
I have met the same problem too.
The Ember::Handlebars::Template
processor has added to the engines of sprockets successfully.
Rails.application.assets.engines
=> {".coffee"=>Sprockets::CoffeeScriptProcessor,
".jst"=>Sprockets::JstProcessor,
".eco"=>Sprockets::EcoProcessor,
".ejs"=>Sprockets::EjsProcessor,
".sass"=>Sass::Rails::SassTemplate,
".scss"=>Sass::Rails::ScssTemplate,
".erb"=>Sprockets::ERBProcessor,
".handlebars"=>Ember::Handlebars::Template,
".hbs"=>Ember::Handlebars::Template,
".hjs"=>Ember::Handlebars::Template}
but when I try to find_asset
=> {:dependencies=>
#<Set: {"environment-version",
"environment-paths",
"processors:type=application/javascript&file_type=application/javascript",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/learning.js",
"processors:type=application/javascript&file_type=application/javascript&pipeline=self",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/adapters.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/mixins.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/custom_model.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/controllers/courses/index_controller.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/controllers/courses/learn_controller.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/controllers/courses/show_controller.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/helpers.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/components/chapter-sidebar_component.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/components/display-comic_component.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/components/display-courseware_component.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/components/display-exercise_component.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/components/display-game_component.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/components/display-quiz_component.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/components/display-video_component.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/components/display-web_component.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/components/section-sidebar_component.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/routes/courses/index_route.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/routes/courses/learn_route.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/routes/courses/show_route.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/routes/index_route.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/initializers.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/router.js",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/adapters",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/mixins",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/custom_model",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/controllers",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/controllers/courses",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/helpers",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/components",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/templates",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/templates/components",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/templates/courses",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/routes",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/routes/courses",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/initializers",
"file-digest:///Users/star/code/neolion_backend/app/assets/javascripts/learning/router"}>,
we can see the handlebars
template were ignored.
app/assets/javascripts/learning/templates
├── components
│ ├── chapter-sidebar.hbs
│ ├── display-comic.hbs
│ ├── display-courseware.hbs
│ ├── display-exercise.hbs
│ ├── display-game.hbs
│ ├── display-quiz.hbs
│ ├── display-video.hbs
│ ├── display-web.hbs
│ └── section-sidebar.hbs
└── courses
├── index.hbs
├── learn.hbs
└── show.hbs
env
sprockets '~> 3.0.1'
sprockets-rails '~> 2.2.4'
@josh How could I fix this ?
I fix it by adding this code in config/application.rb
config.assets.configure do |env|
env.register_engine '.hbs', Ember::Handlebars::Template, mime_type: 'application/javascript'
end
I was running into an issue where handlebars templates weren't rendering at all using sprockets 3.1.0
, sprockets-rails 2.3.1
, ember-rails 0.18.2
, and ember-handlebars-template 0.2.0
and was able to fix it using @justqyx's suggestion.
Seems like the engine is being registered at the wrong level?
I think this is fixed by https://github.com/emberjs/ember-rails/pull/495 . If not fixed yet, please reopen this issue.
We enabled tests under Sprockets 3.0 here, but it still fails:
Here is the demo app: https://github.com/kirs/ember-sprockets-3 (type
rake
to reproduce the issue`)