Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding HAML to the Rails asset pipeline

I would like to serve client side templates that have been pre-processed through HAML. I have tried using the haml_assets gem and adding the following code to an initializer:

Rails.application.assets.register_engine ".haml", Tilt::HamlTemplate

Both of these methods serve the raw HAML and not compiled HAML when I access the asset. How can I add HAML to the pipeline?

like image 342
Zameer Manji Avatar asked Oct 14 '11 15:10

Zameer Manji


1 Answers

Just to clear things up, since I find the current answers a bit irritating (led me to the right direction though)

It works, if i have this line in an initializer file:

# config/initializers/haml_assets.rb
Rails.application.assets.register_engine '.haml', Tilt::HamlTemplate

Throw your haml files into the assets folder, for example:

# app/assets/templates   

Do not use the haml_asset gem though!

like image 128
Samuel Müller Avatar answered Oct 04 '22 09:10

Samuel Müller