You might have already guessed how this code works. We have added a new
require line to
helloworld.rb. This loads the
haml gem. In the controller, we are returning a
haml instead of a string.
Let's see line 5 once again:
5 haml :index
This is a ruby method call. The
haml method has
argument:index. The method will look for a file named
index.haml in the
views folder, generate the HTML from HAML, and return it to the client.
The following method will call the required file:
If the file does not exist in the
views folder or if there are any syntax errors in HAML, then the application will throw an error.
Let's now see
1 %body 2 %h1 3 Hello World!
We will see later that an HTML element can be defined by