Would you like to use
haml in the asset pipeline?
This gem adds
haml support to the Rails 3.1+ asset pipeline. You will also
handlebars_assets as well.
Add this to your
haml_assets now works with the
haml gem. Please update your gemfile to only
You should located your templates under
app/assets; we suggest
//= require_tree ../templates
Inside your templates directory, add your template file. The file should be named as follows
- Convert your haml to HTML
Important! The asset pipeline is not invoking a controller to generate the templates. If you are using existing view templates, you may have to edit templates to remove some references to controller helpers.
ActionView and route helpers are available in your template. If you use
form_for and the related helpers, you should use the new object style, even
if you are writing an edit template, for example
You can render partials within your views. Because this is hacked in, you can
nest your partials as normal, but they must have a recognized format such as
html. For example
Warning this is a potentially confusing option!
If you need to share a partial with Rails views, you can tell
share partials with the Rails app by looking for the templates in
Add this to an initializer:
HamlAssets::Config.look_in_app_views = true
Now your asset pipeline
haml views will additionally look for partials in the
usual Rails location
See this issue from
handlebars_assets for a dicussion of the asset pipeline
and initializers issue 34.
Once you've made your great commits:
- Create a topic branch - git checkout -b my_branch
- Push to your branch - git push origin my_branch
- Create a Pull Request from your branch
- That's it!
- Les Hill : @leshill
- Wes Gibbs : @wgibbs
- Eugene Pimenov (@libc) : Rendering partials
- Raphael Randschau (@nicolai86) : Render partials