O'Reilly logo

Learning Sinatra by Manoj Sehrawat, Sudeep Agarwal

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

Using HAML in a Sinatra application

We will have two files in this case, helloworld.rb and index.haml.

The layout is as follows:

helloworld.rb
views/
          index.haml
helloworld.rb
1 require 'sinatra'
2 require 'haml'
3
4 get '/' do
5   haml :index
6 end
index.haml
1 %body
2   %h1
3     Hello World!

Now, let's start the application:

$ ruby helloworld.rb

After this, open the browser and point it to http://localhost:4567.

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