-
Notifications
You must be signed in to change notification settings - Fork 159
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
Can't get hamlbars to play nicely with handlebars_assets #85
Comments
I changed how registration is done in the fix-sprockets-register experimental branch (which is part of the next version). In order to get it to work for templates of the name "foo.js.hbs.hamlbars": e.g. config/initializers/templating.rb: require 'handlebars_assets'
::HandlebarsAssets.configure do |config|
config.haml_enabled = false
# and/or
config.hamlbars_extensions = []
end I tested on Rails 3.2 locally, does this work for you? |
Thanks @AlexRiedler. This worked great! I tried either one, and they both seem to do the trick. BTW, when looking through config.rb, I noticed there may be a small typo. In the following, there is no 'hbs_extensions' registered in the attr_writer, so I assume you meant '@handlebars_extensions' def handlebars_extensions
@hbs_extensions ||= ['.hbs', 'handlebars']
end Thanks again for the rapid fix. |
@timherby, haha yeah, thanks for notifying me! and no problem! |
One last thing. I tried to simplify to only disabling haml by using this setting: config.haml_enabled = false but then the .hbs registration still kicks in and tries to process the template as haml because HanldeBarsTemplate.is_haml? is solely looking at the registered extensions. It should probably also look at whether haml is enabled. For now, just using this in the configuration works fine: config.hamlbars_extensions = [] |
I just started using handlebars_assets yesterday with the I tried adding |
@rpocklin I assume this is because the separation of pipelines that you are using. (or files are in both folders/symlinked) ? the 'handlebars_assets' gem does take '.hamlbars' files and compile them... they just won't support the 'hb' helper (which is why they are slightly incompatible right now). |
Yeah, my templates for client-side are different than the server-side views. I'm not using the |
I'm trying to use hamlbars with handlebars_assets, but so far have failed to get them to integrate properly.
Out of the box, I tried including both gems:
And when I create a file with a .hamlbars file, it gets compiled properly, but by the handlebars_assets Tilt template, not the hamlbars Template class.
If I change the extension to "file.js.hbs.hamlbars" (as described here https://github.com/jamesotron/hamlbars#chaining-compilation-using-the-rails-asset-pipeline), I get "file.js.haml.js" as my include, and "file.js" cannot even be downloaded directly.
I then decided to pull the latest version of handlebars_assets which changes the initialization order so that the hamlbars template gets used. I did this by changing my gemfile to point to the latest commit in this branch: https://github.com/leshill/handlebars_assets/tree/fix-sprockets-register
as described in issue #73
But that doesn't do the trick. If I keep the filename as "file.hamlbars" no files are included by
If I switch to "file.js.hbs.hamlbars", I run into this issue jimsynz/hamlbars#42 (Illegal nesting: nesting within plain text is illegal). If I follow the advice in that thread, and switch "file.js.hbs.hamlbars" to ".js.hamlbars" but then the handlebars template gets returned uncompiled to the browser.
If anyone has any tips about how to use both gems together, I would really appreciate it. I have cross-posted this to the other gem's forum too (jimsynz/hamlbars#51) for tracking.
The text was updated successfully, but these errors were encountered: