Closed metaskills closed 11 years ago
Hi @metaskills,
Thanks!
Thanks Les!
For anyone watching this issue, I noticed Les was nice enough to put this into a v0.14.0 release. Cheers!
I don't have time to put out a detailed bug report, but this commit seems to break my 3.2.13 installation. I get the HandlebarsTemplates is not defined in js console.
For now I have just rolled back to 0.13.0
Hi @abhishiv,
Any details would be greatly appreciated, I will take a look at this later today.
I can help too if needed. @abhishiv, do you have a stack trace?
Hey guys, there's no stacktrace. The .hbs templates just seem to be ignored. So i just have Uncaught ReferenceError: HandlebarsTemplates is not defined
in the browser.
I have the following in my Gemfile
gem 'rails', '3.2.11'
gem 'handlebars_assets', "0.14.0"
If it's not reproducible let me know. I'll dig more into it.
Hey guys, there's no stacktrace
Whoops :)
So I can confirm this happens and a potential fix, register the template handler early on as possible. In less-rails, I do that in the before_initialize
hook. I have confirmed that this implementation for engine.rb
works all around.
module HandlebarsAssets
class Engine < ::Rails::Engine
config.before_initialize do |app|
next unless app.assets
Sprockets.register_engine('.hbs', TiltHandlebars)
Sprockets.register_engine('.handlebars', TiltHandlebars)
Sprockets.register_engine('.hamlbars', TiltHandlebars) if HandlebarsAssets::Config.haml_available?
Sprockets.register_engine('.slimbars', TiltHandlebars) if HandlebarsAssets::Config.slim_available?
end
end
end
Hi @metaskills,
Glad you found it, please make a new PR and I will pull that in.
Will do... there is one small error in that too.
Done in #73
Great, i'll check it once it's pulled in.
I have a feeling this should fix a similar issue I have been having with maccman/catapult and phonegap.
Thanks
This has been rolled back and a new gem version has been pushed so that folks automatically pulling them in get the new version.
In rare cases with other eninges mounted, using
app.assets
sprockets engine instance causes acan't modify immutable index
errors like this one below when compiling assets.I have found that using
register_engine
withSprockets
solves the issue. Even tho I have authored a few gems likeless-rails
, I am uncertain why this is the case and how the issues really manifested. I can say that it appears that usingSprockets.register_engine
vsapp.assets.register_engine
is the preferred way, see searches below.https://github.com/search?q=Sprockets.register_engine&ref=cmdform&type=Code https://github.com/search?q=app.assets.register_engine&ref=cmdform&type=Code
If required, I would be more than willing to investigate why this may be the best way to register a template engine. For now, I only made it as far as reading the
Sprockets::Index
comments and where the specific exception was raised.