1

I want to use haml in rails 3 project.

Now how to start? How to cofig it?

qichunren
  • 4,405
  • 7
  • 37
  • 48

4 Answers4

7

Just follow the instruction on the HAML Reference page

In short:

For Rails 3, instead add the following line to the Gemfile: gem "haml"

Once it’s installed, all view files with the ".html.haml" extension will be compiled using Haml.

Matthew Manela
  • 16,572
  • 3
  • 64
  • 66
  • If you want to use the scaffold-function with haml too, you will need the rails-haml in development. gem 'haml-rails', :group => :development – Matthias May 08 '12 at 17:51
3

Add haml to your Gemfile

gem "haml"

If you want to use the scaffold-functions too, add html-rails within your development-group

gem 'haml-rails', :group => :development
Matthias
  • 10,816
  • 2
  • 19
  • 12
2

You can do follow this tutorial: where you customise the generators: http://paulbarry.com/articles/2010/01/13/customizing-generators-in-rails-3

or just follow this simple way to do it original post: How do I get Haml to work with Rails?

First, install haml as a plugin

ruby script/plugin install git://github.com/nex3/haml.git

Then, Make sure your views are named with a *.html.haml extension. For example:

`-- app
    `-- views
        |-- layouts
        |   `-- application.html.haml
        `-- users
            |-- edit.html.haml
            |-- index.html.haml
            |-- new.html.haml
            `-- show.html.haml

(Note: You could instead install haml as a gem, but for the sake of simplicity, let's just assume using it as a plugin is the best bet.)

Hope this helps.

Community
  • 1
  • 1
Pavan
  • 17,840
  • 8
  • 59
  • 100
2

I like this tutorial - gives all the steps from the ground up. http://screencasts.org/episodes/using-haml-with-rails-3