O'Reilly logo

Instant Haml by Krzysztof Niksiński

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Quick start – using Haml

Step 1 – integrating with Rails and creating a simple view file

Let's create a simple rails application and change one of the view files to Haml from ERB:

  1. Create a new rails application named blog:
    rails new blog
    
  2. Add the Haml gem to this application's Gemfile and run it:
    bundle install
    
  3. When the gem has been added, generate some views that we can convert to Haml and learn about its basic features. Run the Rails scaffold generator to create a scaffold named post.
    rails g scaffold post
    
  4. After this, you need to run the migrations to create the database tables:
    rake db:migrate
    

    You should get an output as shown in the following screenshot:

Note

Our application is not yet generating Haml views automatically. We will switch it to this ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required